Ok, this really is driving me nuts!!! :(
'All' I am trying to do is get the value of a named element. My XML doc
is:
<?xml version="1.0" encoding="utf-16" standalone="yes " ?>
- <Page>
<Title>Test</Title>
<MetaKeywords>T est</MetaKeywords>
<MetaDescriptio n>Test</MetaDescription >
<Content>Test </Content>
- <Audit>
<LastUpdateBy />
<LastUpdateDate >08/05/2005 09:25:32</LastUpdateDate>
</Audit>
</Page>
So, I want to get the value of the title element - Should return 'Test'.
Heres my code:
Public Sub LoadFromXML(ByV al strXMLFileLocat ion As String)
Me.XMLFileLocat ion = strXMLFileLocat ion
'Dim XMLFileStream As New FileStream(strX MLFileLocation,
FileMode.Open)
Dim XMLDoc As XmlDocument = New XmlDocument
XMLDoc.Load(str XMLFileLocation )
Dim myXMLNodeList As XmlNodeList =
XMLDoc.GetEleme ntsByTagName("T itle")
Me.Title = myXMLNodeList.I tem(0).InnerTex t() <-- This
fails
with error: Object reference not set to an instance of an object.
I've also tried using ...item(1)... - Same error.
Note that this:
Me.Title = myXMLNodeList.C ount.ToString
Returns a value of 1 - So I guess the XML document is found and loaded
correctly.
Any help will be appreciated.
Simon.
--
I am using the free version of SPAMfighter for private users.
It has removed 2212 spam emails to date.
Paying users do not have this message in their emails.
Try www.SPAMfighter.com for free now!