Print Page | Close Window

Getting error "obj ref" writing XMLNode

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=12531
Printed Date: 29 March 2026 at 2:09pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Getting error "obj ref" writing XMLNode
Posted By: vshriniwasan
Subject: Getting error "obj ref" writing XMLNode
Date Posted: 13 November 2004 at 11:09pm

Here is the thing... I am generating the following XML.

<Sites count="13" pCount="1">
    <Site>
        <Title>demoPortal</Title>
        <Url>http://localhost:8000</Url>
        <ID>7f673e14-e991-49e8-a639-bd801debaad0</ID>
    </Site>
    <Site>
        <Title>Ct131</Title>
        <Url>http://localhost:8000/personal/ct131</Url>
        <ID>d071b723-3222-49ae-a765-0744b397b5b5</ID>
    </Site>
</Sites>

I have no problems looping through the nodes and writing it. Code below that works...

objNodeList is Sites...

For Each objNode In objNodeList
   For Each objNodeChild In objNode
      Response.Write(objNodeChild.InnerText)
   Next
Next

When I try to write a specific node, lets say title it gives me "Object reference not set to an instance of an object". Below is the code I am using to replace the above item.

Response.Write(objNodeChild("Title").InnerText)

Is there anyting wrong? Please advise...

Thanks,
Shrini




Replies:
Posted By: Mart
Date Posted: 14 November 2004 at 4:41am
This should work:


 For Each n As XmlNode In doc.ChildNodes
Dim x As String = n("Sites").ChildNodes(0)("Title").InnerText
 Next




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net