Results 1 to 32 of 32

Thread: VB.NET: Get the Attribute and Text out from Xml....[Resolved]

Hybrid View

  1. #1

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230
    ok....i fully understand what you mean..

    now my concept on XPath is much more clearer...
    I have finally resolve all my doubts..

    Thanks Edneeis..
    Last edited by toytoy; Oct 1st, 2004 at 01:32 AM.

  2. #2

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    VB.NET: Get the Attribute and Text out from Xml....[Resolved]

    Say i have these Xml tag
    Code:
    <Books>
          <Title section ="1">
              <Reference web = "www.any.com" topic = "1">
          </Title>
          <Title section ="1">
              <Reference web = "www.idea.com" topic = "2">
          </Title>
          <Title section ="2">
              <Reference web = "www.howTo.com" topic = "3">
          </Title>
          <Title section ="3">
              <Reference web = "www.do.com" topic = "4">
          </Title>
    </Books>
    I want to extract all the web and topic attribute only in Title section "1"...

    Thanks
    Last edited by toytoy; Jan 6th, 2005 at 09:14 AM.

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: VB.NET: Get the Attribute and Text out from Xml....[Unresolved]

    Did you check out the example code I posted in the zip file?

    It shows you how to do that. The only difference would be referring to the topic attribute exactly the way the example does the web attribute.

  4. #4

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    Re: VB.NET: Get the Attribute and Text out from Xml....[Unresolved]

    yeah....cannot..

    Once i selected ID "1" which is the same with two title data..

    it display only the first data of web and topics since two have the same ID..

    Say how to extract all web and topic involve same and different ID into the combo box ..

    Thanks..

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: VB.NET: Get the Attribute and Text out from Xml....[Unresolved]

    Then instead of calling SelectSingleNode use SelectNodes and loop through the results.

  6. #6

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    Re: VB.NET: Get the Attribute and Text out from Xml....[Unresolved]

    From the previous Xml tags:
    Code:
    <Books>
          <Title section ="1">
              <Reference web = "www.any.com" topic = "1">
          </Title>
          <Title section ="5">
              <Reference web = "www.idea.com" topic = "2">
          </Title>
          <Title section ="5">
              <Reference web = "www.howTo.com" topic = "3">
          </Title>
          <Title section ="9">
              <Reference web = "www.do.com" topic = "4">
          </Title>
    </Books>
    Say i have 3 section name for the Title:
    "1" stand for Science, "2" stand for Gerenal and "3" stand for History

    when i receive the section attribute from the server, i have to do some comparing with the number...like 2 to the power of 1 indicate the event of Science, 2 to the power of 2 indicate Gerenal and so on.

    Thus when i receive the number "5" for section in this case, it indicate the events of Science and Gerenal...
    so all those fields with attribute "5" will be extract.......

    The exponent method is:
    Code:
     Public Function pow(ByVal exponent As Integer, ByVal base As Integer)
    
            result = base ^ exponent
            subtotal = result
            total = total + subtotal
            Return total
    
        End Function
    with the above method, what should i do to compare the number with the section attributes correctly and display it to a listbox...

    Currently, i may extract the web and topic.... but it will duplicate the values whenever i extract from it...

    Example: listbox should contain:

    www.howTo.com
    3
    www.idea.com
    2

    But my coding gave me this:

    www.howTo.com
    3
    www.idea.com
    2
    www.howTo.com
    3
    www.idea.com
    2
    www.howTo.com
    3
    www.idea.com
    2
    www.howTo.com
    3
    www.idea.com
    2

    See, when i extract two sets of data, it will duplicate four sets instead...

    Thanks
    Last edited by toytoy; Jan 11th, 2005 at 12:38 AM.

  7. #7

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    Re: VB.NET: Get the Attribute and Text out from Xml....[Unresolved]

    According to the above XML tags...

    I want to extract all attributes and display accordingly...

    I will always have duplicate values...

    That means...my looping is wrong..

    Any ideas how to do a simple and accurate compare loop and extract the required attributes from all the loop into different listbox...

    Thanks

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