472,127 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Test for a nodes existance???

I'm having a problem setting the testing for the existance of a nodes
outerxml property. Below I try to test for the existance before I access
the property, but I receive a null exception error. How do i test for the
existance of this property before I use it?

Thanks,

Lyndon

XmlNode rawMicroAmount =
doc.SelectSingleNode("/iso8583msg/field[24]/subfield[8]/element[7]/key");

XmlNode rawMicroAmountVal =
doc.SelectSingleNode("/iso8583msg/field[24]/subfield[8]/element[7]/value/tex
t()");

writer.WriteStartElement(rawMicroAmount.InnerXml);

if(null!=rawMicroAmountVal.OuterXml)

{

writer.WriteString(rawMicroAmountVal.OuterXml);

}

writer.WriteEndElement();
Nov 12 '05 #1
4 2155
lyndon hughey wrote:
XmlNode rawMicroAmountVal =
doc.SelectSingleNode("/iso8583msg/field[24]/subfield[8]/element[7]/value/tex
t()");


SelectSingleNode() returns null when selects no node. So just test if
rawMicroAmountVal is null.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
lyndon hughey wrote:
XmlNode rawMicroAmountVal =
doc.SelectSingleNode("/iso8583msg/field[24]/subfield[8]/element[7]/value/tex
t()");


SelectSingleNode() returns null when selects no node. So just test if
rawMicroAmountVal is null.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3
Thanks Oleg.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:eK****************@TK2MSFTNGP10.phx.gbl...
lyndon hughey wrote:
XmlNode rawMicroAmountVal =
doc.SelectSingleNode("/iso8583msg/field[24]/subfield[8]/element[7]/value/tex t()");


SelectSingleNode() returns null when selects no node. So just test if
rawMicroAmountVal is null.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #4
Thanks Oleg.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:eK****************@TK2MSFTNGP10.phx.gbl...
lyndon hughey wrote:
XmlNode rawMicroAmountVal =
doc.SelectSingleNode("/iso8583msg/field[24]/subfield[8]/element[7]/value/tex t()");


SelectSingleNode() returns null when selects no node. So just test if
rawMicroAmountVal is null.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by no spam | last post: by
4 posts views Thread by n_o_s_p_a__m | last post: by
reply views Thread by lyndon hughey | last post: by
3 posts views Thread by Green | last post: by
6 posts views Thread by Vmusic | last post: by
reply views Thread by Malcolm Dew-Jones | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.