Philippe Boulos
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.Sel ectNodes(v Doc )
My variable vDoc = "/Transport/BOL/Sheets/Doc [@type='In voice']".
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='In voice' @isValid='true']" but that did not work. Any ideas?
How do I limit my node to the two characteristics?
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(vFileName)
Dim DocNodes As XmlNodeList = xmlDoc.DocumentElement.Sel
My variable vDoc = "/Transport/BOL/Sheets/Doc
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
How do I limit my node to the two characteristics?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Could you upload a small sample file?
ASKER
This is the actual line: <PriceSheet type="Invoice" chargeModel="NORMALIZED_MA NUAL" isSelected="true" isAllocated="false"
I had attempted to disguise it a bit before. I have to select on both TYPE and ISSELECTED.
I had attempted to disguise it a bit before. I have to select on both TYPE and ISSELECTED.
ASKER
I got it. Thanks to Norie. The answer was [@type='Invoice' and @chargeModel='NORMALIZED_M ANUAL' and @isSelected='true']". Once I included all three elements and in order, it worked.
ASKER
<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