Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Using xmldocument.SelectNodes

From: JoeKatz@-----.---
To: 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>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent