Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XML to DataSet
#1
Hey guys

I need to parse out an XML file and load it to a datatable. I have been playing around with the XMl functionality listed in the Help Read Me all day but have not made any real progress ... what would you guys suggest?

Thanks!
Reply
#2
It depends on the structure of your xml file. if the xml is like
Code:
<Variable id="FirstName"> <Value>Saket</Value> </Variable> <Variable id="LastName"> <Value>Kumar</Value> </Variable>

then you can create a function to get xml values

Code:
Public Function GetXMLValue(XMLFile,VariableName) 'Declare local variables. Dim objXMLDom Dim objXMLRoot Dim objXMLField Set objXMLDom = CreateObject("Microsoft.XMLDOM") objXMLDom.async = false objXMLDom.load(XMLFile) Set objXMLRoot = objXMLDom.documentElement Set objXMLField = objXMLRoot.selectSingleNode("Variable[@id='" & Trim(VariableName) & "']/Value") strValue = objXMLField.Text GetXMLValue = trim(strvalue) End Function


Code:
XMLValue = GetXMLValue("C:\File.xml","FirstName")

Now you can set this value into your datatable.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)