(XML) Favourites for WebBrowser

  • Thread starter Thread starter zoneal
  • Start date Start date
Z

zoneal

I'm making a "favourites" for a browser, as i may have said in previous
post. So I want to be able to read a simple xml's <Url>

<Favourites>
<url>http://www.google.ca</url>
</Favourites>

Any Idea's? I've looked around on code sites, but they only let me
display Favourites and URL...

I tried something along the lines of


Dim mx As XmlReader = New XmlTextReader("C:\myxml.xml")Do While
(mx.Read())If mx.NodeType = XmlNodeType.DocumentType
ThenMessageBox.Show(mx.Name)ElseIf mx.NodeType = XmlNodeType.Element
ThenMessageBox.Show(mx.Name & " - " & mx.Value)While
(mx.MoveToNextAttribute())MessageBox.Show(mx.Name & " - " &
mx.Value)End WhileElseIf mx.NodeType = XmlNodeType.Comment
ThenMessageBox.Show(mx.Value)End IfLoop I know this is just a code
example, but I thought I would be able to read whats between the
values, or write between two values.I COULD just have it readthe actual
url instead of the tag url... but whats the fun in that? Will my way
work?In this code, there is something where it could read <Url =
http://www.google.ca> </url>Would this be the same idea? Or would it
not be as efficient?

Thank you
 
use a XPath:

dim xmlNodes as xml.xmlNodeList
dim xmlNode as xml.xmlNode

(code for initialize and load the doc is omitted)

xmlNodes = xmlDoc.SelectNodes("Favourites/url")

for each xmlNode in xmlNodex
msgbox xmlNodes.Value
next


But you will need to convert the special characters *to* and *from* xml,
using the XMLConvert class.


[]s
Cesar

<[email protected]> escreveu na mensagem
I'm making a "favourites" for a browser, as i may have said in previous
post. So I want to be able to read a simple xml's <Url>

<Favourites>
<url>http://www.google.ca</url>
</Favourites>

Any Idea's? I've looked around on code sites, but they only let me
display Favourites and URL...

I tried something along the lines of


Dim mx As XmlReader = New XmlTextReader("C:\myxml.xml")Do While
(mx.Read())If mx.NodeType = XmlNodeType.DocumentType
ThenMessageBox.Show(mx.Name)ElseIf mx.NodeType = XmlNodeType.Element
ThenMessageBox.Show(mx.Name & " - " & mx.Value)While
(mx.MoveToNextAttribute())MessageBox.Show(mx.Name & " - " &
mx.Value)End WhileElseIf mx.NodeType = XmlNodeType.Comment
ThenMessageBox.Show(mx.Value)End IfLoop I know this is just a code
example, but I thought I would be able to read whats between the
values, or write between two values.I COULD just have it readthe actual
url instead of the tag url... but whats the fun in that? Will my way
work?In this code, there is something where it could read <Url =
http://www.google.ca> </url>Would this be the same idea? Or would it
not be as efficient?

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top