Link to home
Start Free TrialLog in
Avatar of Philippe Boulos
Philippe BoulosFlag for United States of America

asked on

How to lmit single node selection to attributes?

I want to read and XML file and get specific information.  Currently, my VB.net code is:

        Dim xmlDoc As New XmlDocument()
        xmlDoc.Load(vFileName)

        Dim DocNodes As XmlNodeList = xmlDoc.DocumentElement.SelectNodes(vDoc )

My variable  vDoc = "/Transport/BOL/Sheets/Doc[@type='Invoice']".

This works fine except when I have two with the same type and I only want to read the one marked valid.
XML = Doc type="Invoice" charge ="Standard" isValid="true"

I tried "/Transport/BOL/Sheets/Doc[@type='Invoice' @isValid='true']" but that did not work.  Any ideas?

How do I limit my node to the two characteristics?
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Philippe Boulos

ASKER

This is the XML data line.
<Doc type="Invoice" charge="Standard" isValid="true" isAllocated="false" currencyCode="USD">

When I use "[@type='Invoice' And @IsValid='true']" it compiles file but I get an invalid token when I run it.  It does not like "/Transport/BOL/Sheets/Doc[@type='Invoice' And @IsValid='true']".
Avatar of Norie
Norie

Could you upload a small sample file?
This is the actual line:       <PriceSheet type="Invoice" chargeModel="NORMALIZED_MANUAL" isSelected="true" isAllocated="false"

I had attempted to disguise it a bit before.  I have to select on both TYPE and ISSELECTED.
I got it.  Thanks to Norie.  The answer was [@type='Invoice' and @chargeModel='NORMALIZED_MANUAL' and @isSelected='true']".  Once I included all three elements and in order, it worked.