3

I have been tasked with upgrading an ancient application that was written in VB6 to VB.NET/.NET Framework 4.6. The program does quite a bit of XML parsing, most of which I have been able to convert to using the System.Xml library however I can't seem to figure out how to handle typed node values. The following appears all over the code:

' VB6
Dim xmlNode As MSXML2.IXMLDOMElement
...
iNodeValue = xmlNode.nodeTypedValue
...
xmlNode.nodeTypedValue = iNodeValue

I have figured out how to get a node's typed value via XPathNavigator, however, I can't seem to figure out how to assign the value of a typed node. I wasn't able to turn up much on this topic online, but my google-fu is weak. Can anyone suggest how I might go about doing this or offer an alternative? Any help would be greatly appreciated.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Mythikos
  • 119
  • 12
  • In vb.net use the class XmlDocument or XDocument (xml linq). Add to you module : 1)import System.Xml 2) import System.Xml.Linq – jdweng Nov 21 '17 at 10:30
  • @jdweng , Im not asking what libraries to use to parse xml, I'm asking how to assign a value to a typed node like in the example code above. – Mythikos Nov 21 '17 at 16:51
  • The real question is why are you using a library that is 15 years old? Do you have the original VB6 code that you can post. – jdweng Nov 21 '17 at 23:02
  • You cannot assign a value to a TYPE. You need to assign a value to an object. This library has been obsoleted about 15 years ago. It is xml version 2 and xml version 3 is the oldest library I found in my version of windows. – jdweng Nov 21 '17 at 23:19
  • Support for the nodeTypedValue property was ended in MSXML 6.0. I can't find any reference to it in the System.XML namespace so I don't know how you are getting the nodeTypedValue. https://msdn.microsoft.com/en-us/library/ms762308(v=vs.85).aspx, https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlnode?view=netframework-4.7.1#Properties, https://learn.microsoft.com/en-us/dotnet/api/system.xml.xpath.xpathnavigator?view=netframework-4.7.1#Properties – jac Nov 21 '17 at 23:30
  • @jac I mentioned in the original question that I am rewritting a program that was originally written in VB6. The code snippet is a snippet of VB6 from the program (hence of comment). I am trying to find an equivalent to nodeTypedValue in newer standards. – Mythikos Nov 22 '17 at 18:47

1 Answers1

1

To anyone wondering about this, in order to resolve my issue, I ended up using the XmlDocument class to get the node's value from the XML, and then converted the string value to the datatype needed. For example,

string sValue = xmlDoc.SelectSingleNode("//testint").InnerText
int iValue = Integer.Parse(sValue)

Integer.TryParse() would also be a great option if you are concerned about the data that may be retrieved.

Mythikos
  • 119
  • 12