Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml dom

Status
Not open for further replies.

amiw

Programmer
Apr 1, 2003
113
GB
hi, i am getting an error when i am accessing the R node in an xml file, below is the typical data found in the R node. the line that seems to be causing the problem is this one Response.Write(Node.selectSingleNode("R").text)

'--- one of the R nodes in the xml file
<R>
- <![CDATA[ ]]>
</R>


''' a snippet of my code
Set objRoot = objDom.documentElement
For iCount= 1 to CInt(resultLength)
set Node = objRoot.selectSingleNode(&quot;RESULTS/SITE[@I=&quot; & CInt(iCount)& &quot;]&quot;)
Response.Write(Node.selectSingleNode(&quot;R&quot;).value)
Next

anyone got any ideas?
thanks
Mic.
 
Are you in VB6 or .NET?

If in VB6, do this:
Code:
Dim MyMode As MSXML2.IXMLDOMNode
Dim sText as string

MyNode = Node.selectSingleNode(&quot;R&quot;)
If MyNode Is Nothing Then
  ' Didn't find R node
Else
  sText = MyNode.Text
End If
Response.Write(sText)
If you're in .NET, you should be aware that the text node is no longer implicitly provided to you via the .Text property. You must either use the &quot;text()&quot; function in your XPath query, or check the child nodes for nodes of type XmlText. The XPath route is easiest (sample is in C#, sorry):
Code:
XmlNode RNode;
RNode = MyDoc.SelectSingleNode(&quot;RESULTS/SITE[@I=&quot; + iCount.ToString() + &quot;]/text()&quot;);
if (RNode == null) {
  // Didn't find R Node
}
else
{
   Response.Write(RNode.Value);
}

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top