Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML node elements with Hyphens 1

Status
Not open for further replies.

Dashley

Programmer
Dec 5, 2002
925
US
I'm consuming a webservice into an XMLdocument using a namespacemanager. (ASP.net VB, VS 2008). Well this webservice has dashes(or hyphens) in the XML nodes.
There are 1 to 5 possible weight amounts I need to itterate through. Problem is I can't declare (Dim) a value with a "-" in it. Can someone point me in the right direction.

Thanks

<weight-amount>400.0</weight-amount>



Code:
Dim nodelist As XmlNodeList
Dim root As XmlElement = xmldoc.DocumentElement

nodelist = root.SelectNodes("/customer-rate-response/rate-items/weight-amount", mgr)
            
Dim weight-amount As XmlNode  '** End of statement Error

for each weight-amount in Nodelist
 
There is no bearing between xml document's node name and varaible name used in vb or any other application, in general, parsing it. Nothing forces on the vb variable be named "weight-amount", nothing.
 
Thanks Tsuji.

It's a practice I've always done and when it didn't work this time I went out searching for ways to remove or replace the hyphens.

Its working fine now.
Thanks again

Code:
Dim nodelist As XmlNodeList
Dim root As XmlElement = xmldoc.DocumentElement
Dim weighcalc As Int32 = 0
Dim weightamount As XmlNode

nodelist = root.SelectNodes("/customer-rate-response/rate-items/weight-amount", mgr)

 For Each weightamount In nodelist

   weighcalc = (weighcalc + weightamount.InnerText)

 Next

FXFE_RTNDATA.weightamountstr = Convert.ToString(weighcalc)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top