EDN Admin
Well-known member
Im trying to select a single node from an XML document... the structure of the XML document is as follows.
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; utf-8<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; accounts<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; username<span style="color:Blue; >TestingUser<span style="color:Blue; </<span style="color:#A31515; username<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; accounts<span style="color:Blue; >
[/code]
This is the snippet of code that I am using to try and select the username node.
<div style="color:Black;background-color:White; <pre>
System :: Xml :: XmlDocument^ xml = <span style="color:Blue; gcnew System :: Xml :: XmlDocument ( );
xml -> Load ( filePath );
String^ username = xml -> SelectSingleNode ( <span style="color:#A31515; "username" ) -> OuterXml;
[/code]
This is the Exception that I am receiving...
An unhandled exception of type System.NullReferenceException occurred in MyApp.exe
Additional information: Object reference not set to an instance of an object.
View the full article
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; utf-8<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; accounts<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; username<span style="color:Blue; >TestingUser<span style="color:Blue; </<span style="color:#A31515; username<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; accounts<span style="color:Blue; >
[/code]
This is the snippet of code that I am using to try and select the username node.
<div style="color:Black;background-color:White; <pre>
System :: Xml :: XmlDocument^ xml = <span style="color:Blue; gcnew System :: Xml :: XmlDocument ( );
xml -> Load ( filePath );
String^ username = xml -> SelectSingleNode ( <span style="color:#A31515; "username" ) -> OuterXml;
[/code]
This is the Exception that I am receiving...
An unhandled exception of type System.NullReferenceException occurred in MyApp.exe
Additional information: Object reference not set to an instance of an object.
View the full article