Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Problems with SelectNodes [Thread Next] Re: Problems with SelectNodesTo: NULL Date: 4/4/2006 1:51:00 PM
Joe, if you are iterating through each node in the node list, and thats
really like a for each XmlNode node in myXmlNodeList, why can't you just
call SelectSingleNode() on the current XmlNode for the "disposition" node?
If the return value is non-null, you know you've got one there in that
set....
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxmlnodeclassselectsinglenodetopic1.asp
"Joe" <eternale1@g...> wrote in message
news:1144165263.591665.56630@z......
> This is all being done in .NET. I'm using an xmldocument and I load
> XML into it that i received back from a web service. Below is a
> "section" of that chunk of xml. Now for each section i use the
> xmld.selectnodes("/xmlhistory/violation") to create an xmlnodelist for
> all the chunks that are "violation" nodes. Once I have that into an
> xmlnodelist , i iterate through them using for each xmlnode in
> xmlnodelist. Inside this for loop i'm gathering the values of each tag
> and creating a nice html table that will later be stored. Now once
> inside this for loop i'm running into an issue. In some cases this xml
> below will have additional fields such as <disposition> but sometimes
> it won't. How can I check while in this for loop if the tag of
> <disposition> is present. If it is I want to ( _disposition =
> xmlnode.Item("disposition").InnerText ) grab the value , if its not I
> want to ignore that tag all together. I attempted to grab this value
> initially in the for loop using
> selectnodes(/xmlhistory/violation/disposition/) to see if it exists.
> then used xmlnodelist.count to see if the value was greater then 0.
> But the problem with that is in some cases there will be multiple
> violation sections and one or two of them could have disposition and
> one might not. meaning my count value will still be greater then 0.
> But that doesn't tell me which violation section has or doesn't have
> that tag.
>
> <xmlhistory>
> <violation>
> <acd>BLAH</acd>
> <city-location>BLAH</city-location>
> <court>BLAH</court>
> <description>BLAH</description>
> <event-type>BLAH</event-type>
> <violation-date>BLAH</violation-date>
> <state-code>BLAH</state-code>
> </violation>
> </xmlhistory>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
