Hi
I am new to XML. I have a file with first few lines like:
<?xml version="1.0" ?>
<LandXML xmlns=" xmlns:xsi=" xsi:schemaLocation=" version="1.0" date="2002-07-12" time="12:48:14" readOnly="true" language="English" LandXMLId="2000003">
<Units>
<Metric areaUnit="squareMeter" linearUnit="meter" volumeUnit="liter" temperatureUnit="celsius" pressureUnit="milliBars" angularUnit="decimal dd.mm.ss" directionUnit="decimal dd.mm.ss"/>
</Units>
I am trying to use DOM to access the information. The following code does not find "Units" element.
Public objNodes As IXMLDOMNodeList
Public objBookNode As IXMLDOMNode
Public objADORS As New ADODB.Recordset
Public objADOCnn As New ADODB.Connection
objXMLDOM.async = False
If Not objXMLDOM.Load("D:\Bernie\More XML Files\Extract 4 Surveys.xml") Then
MsgBox "Error: " & objXMLDOM.parseError.reason
Exit Sub
End If
Set objNodes = objXMLDOM.selectNodes("/LandXML/Units")
If objNodes.Length <= 0 Then
MsgBox "No records to be inserted!"
Exit Sub
End If
When I execute this code I get the length of the node list as zero. But if I remove the stuff after "LandXML" in the second line and just have <LandXML>, it works OK. Is there any way to avoid this?
Thanks,
I am new to XML. I have a file with first few lines like:
<?xml version="1.0" ?>
<LandXML xmlns=" xmlns:xsi=" xsi:schemaLocation=" version="1.0" date="2002-07-12" time="12:48:14" readOnly="true" language="English" LandXMLId="2000003">
<Units>
<Metric areaUnit="squareMeter" linearUnit="meter" volumeUnit="liter" temperatureUnit="celsius" pressureUnit="milliBars" angularUnit="decimal dd.mm.ss" directionUnit="decimal dd.mm.ss"/>
</Units>
I am trying to use DOM to access the information. The following code does not find "Units" element.
Public objNodes As IXMLDOMNodeList
Public objBookNode As IXMLDOMNode
Public objADORS As New ADODB.Recordset
Public objADOCnn As New ADODB.Connection
objXMLDOM.async = False
If Not objXMLDOM.Load("D:\Bernie\More XML Files\Extract 4 Surveys.xml") Then
MsgBox "Error: " & objXMLDOM.parseError.reason
Exit Sub
End If
Set objNodes = objXMLDOM.selectNodes("/LandXML/Units")
If objNodes.Length <= 0 Then
MsgBox "No records to be inserted!"
Exit Sub
End If
When I execute this code I get the length of the node list as zero. But if I remove the stuff after "LandXML" in the second line and just have <LandXML>, it works OK. Is there any way to avoid this?
Thanks,