469,319 Members | 1,937 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,319 developers. It's quick & easy.

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 2053
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
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.