Re: VB.NET: Get the Attribute and Text out from Xml string

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: One Handed Man \( OHM - Terry Burns \) ("One)
Date: 09/30/04


Date: Thu, 30 Sep 2004 15:12:22 +0100

Hi Chris.

Thanks for your reply.

> It's probably because whatever tool he used to post the message removed
the
> indenting. Although, I think the .xml is strange. Why is the Author tag
> listed inside the Title tag? It seems that the Title should be an
> attribute of Book:
>

Like you, I was pointing out the Tag nesting not the indentation. He didnt
have a <Books> Element enclosing everything else which I found strange.

I'm not entirely sure what the OP is after and it would not suprise me if
they were perhaps a little confused regarding structure and formation. I
guess if they come back we might find out.

-- 
OHM ( Terry Burns )
 . . .  One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:1sfmu9i6jbjn4.u9j6vgfltmws$.dlg@40tude.net...
> On Thu, 30 Sep 2004 11:27:02 +0100, One Handed Man ( OHM - Terry Burns )
> wrote:
>
> > I would have expected the xml to look more like this really. Is there
any
> > reason why it is laid out the way you have it, or are you just playing
with
>
> <Books>
>     <Book ID="1" Title="Book Title Here">
> <Author>Hello</Author>
>         <Reference web = "www.reference.com" topic = "In thing">
>     </Book>
>     <Book ID="2" Title="Second Book Title">
>         <Author>Thanks</Author>
>         <Reference web = "www.titlebook.com" topic = "Out thing">
>     </Book>
> </Books>
>
>
> Toytoy:  As OHM stated, it is not clear what you want.  Are you saying
that
> you need to get a particular <Book> node from your xml?  Books by a
certain
> author?  Books with a certain Topic?
>
> Using the xml above:
>
> '** BEGIN CODE HERE
>
> Dim xDoc An New XmlDocument
> xDoc.Load("books.xml")
>
> 'To select a list of books by a particular author:
> Dim nodeList1 As XmlNodeList
> Dim xNode As XmlNode
> Dim root As XmlElement = xDoc.DocumentElement
>
> 'Get a list of books authored by Thanks
> nodeList1 = root.SelectNodes("/Books/Book[Author=""Thanks""]")
>
> 'Get a book with a certain title:
> xNode = root.SelectSingleNode("/Books/Book[@Title=""Book Title Here""]")
>
> 'Get books with a certain topic:
> nodeList1 = root.SelectNodes("/Books/Book/Reference[@Topic=""In Thing""]")
>
> '** END CODE
>
>
> Hope this helps
>
> -- 
> Chris
>
> dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
>
> To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
> replace certain words in my E-Mail address.


Relevant Pages