Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XML to DataSet
#2
Solved: 11 Years, 4 Months ago
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


Messages In This Thread
XML to DataSet - by bludlust - 07-31-2009, 12:14 AM
RE: XML to DataSet - by Saket - 07-31-2009, 04:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)