Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Using xmldocument.SelectNodes Using xmldocument.SelectNodesTo: NULL Date: 4/4/2006 8:39:00 AM
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 | |||
|
