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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nextsibling grief

Status
Not open for further replies.

Dashley

Programmer
Dec 5, 2002
925
0
0
US
vb.net VS 2012


<?xml version="1.0" encoding="UTF-8"?>
-<XMLRateQuote xmlns=" xmlns:xsi=" xmlns:xsd="//list is shortened for your viewing pleasure

-<ExtraServiceBreakdown>-
<XMLAccessorial>
<Id>ISP</Id>
<Description>Inside Pickup Fee</Description>
<Cost>124.45</Cost>
</XMLAccessorial>
-<XMLAccessorial>
<Id>HTA</Id>
<Description>Heavy Traffic Congestion Fee-Destination</Description>
<Cost>35.00</Cost>
</XMLAccessorial>
</ExtraServiceBreakdown>
</XMLRateQuote>




I'm looping through the <XMLAccessorial> node. [Dim access As XmlElement = DirectCast(xmldoc.SelectSingleNode("/df:XMLRateQuote/df:ExtraServiceBreakdown/df:XMLAccessorial", mgr), XmlElement)] When I fire off the access.nextsibling all I get is the same ID, Description, and cost. (ISP,Inside Pickup,124.45) . Next sibling would be (HTA, Heavy Traffic COnjestion Fee destination, 35.00)




Dim access As XmlElement = DirectCast(xmldoc.SelectSingleNode("/df:XMLRateQuote/df:ExtraServiceBreakdown/df:XMLAccessorial", mgr), XmlElement)

Dim AccessorialID As XmlElement
Dim AccessorialDescription As XmlElement
Dim AccessorialCost As XmlElement
Dim strAccessorialID As String
Dim strAccessorialCost As String
Dim strAccessorialDescription As String

Do While (access IsNot Nothing)

If access.LocalName = "XMLAccessorial" Then
AccessorialID = DirectCast(xmldoc.SelectSingleNode("/df:XMLRateQuote/df:ExtraServiceBreakdown/df:XMLAccessorial/df:Id", mgr), XmlElement)
strAccessorialID = AccessorialID.InnerText.ToString
AccessorialDescription = DirectCast(xmldoc.SelectSingleNode("/df:XMLRateQuote/df:ExtraServiceBreakdown/df:XMLAccessorial/df:Description", mgr), XmlElement)
strAccessorialDescription = AccessorialDescription.InnerText.ToString
AccessorialCost = DirectCast(xmldoc.SelectSingleNode("/df:XMLRateQuote/df:ExtraServiceBreakdown/df:XMLAccessorial/df:Cost", mgr), XmlElement)
strAccessorialCost = AccessorialCost.InnerText.ToString
End If

access = access.NextSibling

Loop
 
forum796

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Finally got it working. Posting incase someone else needs it



Dim doc As XmlDocument = New XmlDocument()
doc.Load("C:\Users\Dashley\documents\visual studio 2012\Projects\FreightRater\FreightRater\VITRtest.xml")
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(doc.NameTable)
nsmgr.AddNamespace("df", doc.DocumentElement.NamespaceURI)

Dim nodeList As XmlNodeList
Dim root As XmlElement = doc.DocumentElement
nodeList = root.SelectNodes("df:ExtraServiceBreakdown/df:XMLAccessorial", nsmgr)

Dim m_node As XmlNode
Dim description As String
Dim Id As String = Nothing
Dim Cost As String = Nothing

For Each m_node In nodeList
Id = m_node.Item("Id").InnerText
description = m_node.Item("Description").InnerText
Cost = m_node.Item("Cost").InnerText

Response.Write(Id & ", " & description & ", " & Cost & "<BR />")
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top