|
-
Jun 2nd, 2006, 10:12 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Jun 2nd, 2006, 10:42 AM
#2
Thread Starter
Hyperactive Member
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:
Dim xmldoc2 As New XmlDocument
xmldoc2.Load(Application.StartupPath & "\books.xml")
Dim Node As Xml.XmlNode = xmldoc2.DocumentElement.SelectSingleNode( _
"book[@id=" & Chr(34) & "2" & Chr(34) & "]")
If Not Node Is Nothing Then
' Need to msgbox the value inside <text>
End If
-
Jun 2nd, 2006, 11:03 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] how to select parentnode in xml with certan id
ok i got that part too:
VB Code:
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|