Results 1 to 2 of 2

Thread: select node within Nodelists

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2011
    Posts
    16

    select node within Nodelists

    I have some xml loaded in a NS manager.
    I've gathered up a node list of all "<typeCharge>"nodes of which there are 7
    I iterate through the nodes for the one named "FS" and find it.
    I can't seem to figure out how to grab the "<charges>" node below it (charge is 45.67).
    Any help would be appreciated.

    Thanks

    Code:
    Dim charges As XmlNodeList = DirectCast(xmldoc.SelectNodes("df:root/df:details/df:typeCharge", mgr), XmlNodeList)
    
    
      For typchg As Int32 = 0 To charges.Count - 1
                If Trim(charges.Item(typchg).InnerText) = ("FS") Then
    
     *** how do I grab the charges node associated with this
    
                End If
            Next
    - <details>
    <typeCharge>P</typeCharge>
    <description />
    <weight>600</weight>
    <class>60</class>
    <rate>80.12</rate>
    <charges>480.72</charges>
    <typeCharge>P</typeCharge>
    <description />
    <weight>650</weight>
    <class>60</class>
    <rate>80.12</rate>
    <charges>520.78</charges>
    <typeCharge>GFC</typeCharge>
    <description>GROSS FRT CHG</description>
    <weight />
    <class />
    <rate />
    <charges>1001.50</charges>
    <typeCharge>D8400</typeCharge>
    <description>84.00% DISCOUNT</description>
    <weight />
    <class />
    <rate />
    <charges>841.26</charges>
    <typeCharge>NFC</typeCharge>
    <description>NET FRT CHG</description>
    <weight />
    <class />
    <rate />
    <charges>160.24</charges>
    <typeCharge>FS</typeCharge>
    <description>LTL FUEL SURCHARGE OF 28.50%</description>
    <weight />
    <class />
    <rate />
    <charges>45.67</charges>
    <typeCharge>TTL</typeCharge>
    <description />
    <weight>1250</weight>
    <class />
    <rate />
    <charges>205.91</charges>
    </details>

  2. #2
    Member PBertie's Avatar
    Join Date
    Aug 2011
    Location
    Newcastle Upon Tyne
    Posts
    55

    Re: select node within Nodelists

    I think your xml file should be structured with description, weight, class, rate and charges as children of the typeCharge, like:
    Code:
    <typeCharge name="FS">
      <description>LTL FUEL SURCHARGE OF 28.50&#37;</description>
      <weight />
      <class />
      <rate />
      <charges>45.67</charges>
    </typeCharge>
    Then you loop through the typCharge items and check to see if its the one you want. Once you have it you get its children and find the charges one.

    Or, you could have it like below and replace ITEM with something else:
    Code:
    <ITEM>
      <typeCharge>FS</typeCharge>
      <description>LTL FUEL SURCHARGE OF 28.50%</description>
      <weight />
      <class />
      <rate />
      <charges>45.67</charges>
    </ITEM>
    Both these ways the items are grouped in a way that they relate to each other.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width