Results 1 to 3 of 3

Thread: [resolved] [2005] how to select parentnode in xml with certain id

  1. #1

    Thread Starter
    Hyperactive Member jonwondering's Avatar
    Join Date
    May 2005
    Posts
    311

    Resolved [resolved] [2005] how to select parentnode in xml with certain id

    Hi, I have the following xml doc:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <books>
      <book id="1">
        <title>book1title</title>
        <text>book1text</text>
      </book>
      <book id="2">
        <title>book2title</title>
        <text>book2text</text>
      </book>
    </books>
    I was wondering how it's possible to select say book with id 2, so that later I could use that book's title and text. I am just trying to figure this out so that later I could use something like MsgBox(Book.Title)...

    Any suggestions?
    Last edited by jonwondering; Jun 2nd, 2006 at 12:27 PM.

  2. #2

    Thread Starter
    Hyperactive Member jonwondering's Avatar
    Join Date
    May 2005
    Posts
    311

    Re: [2005] how to select parentnode in xml with certan id

    Ok i figure out how to get Parent Node, now if only I could get Child Node of "text"...

    This is what I have so far:

    VB Code:
    1. Dim xmldoc2 As New XmlDocument
    2.         xmldoc2.Load(Application.StartupPath & "\books.xml")
    3.  
    4.         Dim Node As Xml.XmlNode = xmldoc2.DocumentElement.SelectSingleNode( _
    5.                   "book[@id=" & Chr(34) & "2" & Chr(34) & "]")
    6.  
    7.         If Not Node Is Nothing Then
    8.  
    9.             ' Need to msgbox the value inside <text>
    10.  
    11.         End If

  3. #3

    Thread Starter
    Hyperactive Member jonwondering's Avatar
    Join Date
    May 2005
    Posts
    311

    Re: [2005] how to select parentnode in xml with certan id

    ok i got that part too:

    VB Code:
    1. MsgBox(Node.Item("text").InnerText)
    team work!

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