Solved

VB.NET Webbrowser XML

Posted on 2006-07-24
10
631 Views
Last Modified: 2008-03-17
I have a Webbrowser on my programme which runs a webpage which is an XML file, so on the webbrowser1 i can see:

  <?xml version="1.0" encoding="UTF-8" ?>
- <NLAML>
- <SourceMetaData>
  <Property FormalName="Publication_Name" Value="The Independent" />
  <Property FormalName="Publication_SubSource" Value="Media Weekly" />
  <Property FormalName="Edition" Value="01" />
  <Property FormalName="Publication_Date" Value="20060724" />
  <Property FormalName="Day" Value="Monday" />
  <Property FormalName="Page_Section" Value="inside story / inside story" />
  <Property FormalName="Page_Number" Value="8,9" />
  </SourceMetaData>
- <DescriptiveMetaData>
  <Property FormalName="NLAArticleID" Value="1612202" />
  <Headline>INSIDE STORY Take the office on holiday</Headline>
  <Byline>DJ Taylor</Byline>
  <Property FormalName="WordCount" Value="2082" />
  </DescriptiveMetaData>
  - <DescriptiveMetaData>
  <Property FormalName="NLAArticleID" Value="1616044" />
  <Headline><strong>England's ambitions turning to Ashes with injury debacle </strong></Headline>
  <Byline>NEIL DRYSDALE</Byline>
  <Property FormalName="WordCount" Value="847" />
  </DescriptiveMetaData>
- <SourceMetaData>
  <Property FormalName="Publication_Name" Value="The Guardian" />
  <Property FormalName="Publication_SubSource" Value="G2" />
  <Property FormalName="Edition" Value="01" />
  <Property FormalName="Publication_Date" Value="20060724" />
  <Property FormalName="Day" Value="Monday" />
  <Property FormalName="Page_Section" Value="Women / Women" />
  <Property FormalName="Page_Number" Value="18,19" />
  </SourceMetaData>
- <DescriptiveMetaData>
  <Property FormalName="NLAArticleID" Value="1611495" />
  <Headline><strong>New trend alert: starlets bite back! </strong></Headline>
  <Byline>Kira Cochrane</Byline>
  <Property FormalName="WordCount" Value="1341" />
  </DescriptiveMetaData>
- <SourceMetaData>
  <Property FormalName="Publication_Name" Value="Metro" />
  <Property FormalName="Publication_SubSource" Value="null" />
  <Property FormalName="Edition" Value="01" />
  <Property FormalName="Publication_Date" Value="20060724" />
  <Property FormalName="Day" Value="Monday" />
  <Property FormalName="Page_Section" Value="" />
  <Property FormalName="Page_Number" Value="21" />
  </SourceMetaData>
- <DescriptiveMetaData>
  <Property FormalName="NLAArticleID" Value="1616490" />
  <Headline><strong>The girl who's not afraid of spiders </strong></Headline>
  <Byline>JAYNE ATHERTON</Byline>
  <Property FormalName="WordCount" Value="390" />
  </DescriptiveMetaData>
- <SourceMetaData>
  <Property FormalName="Publication_Name" Value="The Sun" />
  <Property FormalName="Publication_SubSource" Value="null" />
  <Property FormalName="Edition" Value="01" />
  <Property FormalName="Publication_Date" Value="20060724" />
  <Property FormalName="Day" Value="Monday" />
  <Property FormalName="Page_Section" Value="" />
  <Property FormalName="Page_Number" Value="22" />
  </SourceMetaData>
- <DescriptiveMetaData>
  <Property FormalName="NLAArticleID" Value="1612273" />
  <Headline>NO SEX IN THE CITY</Headline>
  <Byline>SHARON MARSHALL</Byline>
  <Property FormalName="WordCount" Value="511" />
  </DescriptiveMetaData>
- <SourceMetaData>
  <Property FormalName="Publication_Name" Value="The Sun" />
  <Property FormalName="Publication_SubSource" Value="null" />
  <Property FormalName="Edition" Value="02" />
  <Property FormalName="Publication_Date" Value="20060724" />
  <Property FormalName="Day" Value="Monday" />
  <Property FormalName="Page_Section" Value="" />
  <Property FormalName="Page_Number" Value="22" />
  </SourceMetaData>
- <DescriptiveMetaData>
  <Property FormalName="NLAArticleID" Value="1618375" />
  <Headline>IS the colour of a man's carpets a good enough basis to end a potential relationship?</Headline>
  <Byline>Sharon Marshall</Byline>
  <Property FormalName="WordCount" Value="520" />
  </DescriptiveMetaData>
- <SourceMetaData>
  <Property FormalName="Publication_Name" Value="Evening Standard" />
  <Property FormalName="Publication_SubSource" Value="null" />
  <Property FormalName="Edition" Value="01" />
  <Property FormalName="Publication_Date" Value="20060724" />
  <Property FormalName="Day" Value="Monday" />
  <Property FormalName="Page_Section" Value="ENTERTAINMENT TONIGHT CINEMA" />
  <Property FormalName="Page_Number" Value="43" />
  </SourceMetaData>
- <DescriptiveMetaData>
  <Property FormalName="NLAArticleID" Value="1619298" />
  <Headline><strong>CRITIC'S CHOICE </strong>TOP TEN FILMS</Headline>
  <Byline>DEREK MALCOLM</Byline>
  <Property FormalName="WordCount" Value="489" />
  </DescriptiveMetaData>
  </NLAML>

How can i programatically extract each XML tag called VALUE and put it into say another textbox??

0
Comment
Question by:bolox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 4

Expert Comment

by:programmer1024
ID: 17169411
What language are you coding this in?
0
 
LVL 5

Accepted Solution

by:
tokabi earned 250 total points
ID: 17169736
If you can get your XML into an XmlDocument you can use an XPath query to extract all the Value attributes, here is an example reading the XML from a disk file:

        Dim xtr As New System.Xml.XmlTextReader("C:\\testfile.xml")
        xtr.WhitespaceHandling = Xml.WhitespaceHandling.None
        Dim xd As New System.Xml.XmlDocument
        xd.Load(xtr)

        Dim xnl = xd.DocumentElement.SelectNodes("//@Value")

        Dim strValues As New System.Text.StringBuilder

        For Each xnod As System.Xml.XmlNode In xnl
            strValues.Append(xnod.Value)
            strValues.Append(", ")
        Next

        TextBox1.Text = strValues.ToString()

The XPath expression //@Value matches any attribute called Value in your XML and returns a node collection in xnl, you can then iterate through this node collection and extract the text with xnod.Value. here I'm just concatanating the nodes into a huge string which gets displayed in TextBox1.
0
 
LVL 1

Author Comment

by:bolox
ID: 17174333
How do i copy from the webbrowser1 document into an XML file on the fly?  (VB.net BTW)

Wouldnt it slow this process down doing this?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 5

Expert Comment

by:tokabi
ID: 17174486
How are you navigating to the XML file?

using Response.Redirect("xmlfile.xml") or are you loading it and displaying it inside a control?
0
 
LVL 1

Author Comment

by:bolox
ID: 17308879
It goes straight there the URl i post to gives the XML as the result,

the XML is on screen (XML file visible)
0
 
LVL 5

Expert Comment

by:tokabi
ID: 17309037
what code are you using exactly to get the XML back?
0
 
LVL 1

Author Comment

by:bolox
ID: 17309101
im just passing the following:

WebBrowser1.Navigate("http://www.website.com/NLAAPI.dll/SearchDatabase?format=XML&searchterm=" & SearchText)

This results in XML being displayed as above on the browser page,
0
 
LVL 1

Author Comment

by:bolox
ID: 17309110
I am not using any code as of yet i want to extract the webbrowser1 and then search though each term in the XML document
for example display in a text box ONLY the Values of


<Property FormalName="Publication_Date" Value="20060724" />
AND THEN

  <Property FormalName="Page_Section" Value="inside story / inside story" />
0
 
LVL 5

Expert Comment

by:tokabi
ID: 17309130
does the navigation have to be done in javascript or can you change it to use vb.net on the server?
0
 
LVL 1

Author Comment

by:bolox
ID: 17457032
soz, i have been pushed onto another project now, Thankyou for your help, i am nearly there with this now,

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question