XML question

  • Thread starter Thread starter Bryan Dickerson
  • Start date Start date
B

Bryan Dickerson

Warning: XML Newbie

If I am programming for an XML document that could have up to 4 address
lines in a particular segment, how do I test for the existence of, say,
AddrLine2 (and by extension Line 3 & Line 4)? Currently, I'm fairly assured
that I don't have to test for the existence of AddrLine1, but this is the
xPath to it:

xNode = xmlPO.SelectSingleNode( _
"//SOAP-ENV:Body/PurchaseOrder/OrderHeader/Partner[@Relationship='ShipTo']/Address/AddrLine1",
xNSM)

TIA!
 
Warning: XML Newbie

If I am programming for an XML document that could have up to 4
address lines in a particular segment, how do I test for the existence
of, say, AddrLine2 (and by extension Line 3 & Line 4)? Currently, I'm
fairly assured that I don't have to test for the existence of
AddrLine1, but this is the xPath to it:

xNode = xmlPO.SelectSingleNode( _
"//SOAP-ENV:Body/PurchaseOrder/OrderHeader/Partner[@Relationsh
ip='ShipTo']/Address/AddrLine1",
xNSM)

Why wouldn't
"//SOAP-ENV:Body/PurchaseOrder/OrderHeader/Partner[@Relationship=
'ShipTo']/Address/AddrLine2", xNSM)
................................^.........
work?

And what do you mean by 'test for'?
 
That's kinda what I'm asking. My 'best coding practices' senses tell me
that I should code to see if AddrLine2 is present in the document before I
try to pull something out of the segment/node/whatever. Since AddrLine2 is
hardcoded in a string, I want to see if it is there first. Sorta' like "If
Object Is Not Nothing Then Whatever." The other question, then, is if I
just say "xNode = xmlPO.SelectSingleNode(".../AddrLine2", xNSM)", will the
instruction bomb if "AddrLine2" is not present in the document? Or will it
just contain nulls/blanks?

miktro said:
Warning: XML Newbie

If I am programming for an XML document that could have up to 4
address lines in a particular segment, how do I test for the existence
of, say, AddrLine2 (and by extension Line 3 & Line 4)? Currently, I'm
fairly assured that I don't have to test for the existence of
AddrLine1, but this is the xPath to it:

xNode = xmlPO.SelectSingleNode( _
"//SOAP-ENV:Body/PurchaseOrder/OrderHeader/Partner[@Relationsh
ip='ShipTo']/Address/AddrLine1",
xNSM)

Why wouldn't
"//SOAP-ENV:Body/PurchaseOrder/OrderHeader/Partner[@Relationship=
'ShipTo']/Address/AddrLine2", xNSM)
...............................^.........
work?

And what do you mean by 'test for'?
 
Back
Top