Solved

VB.NET Webbrowser XML

Posted on 2006-07-24
10
612 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
  • 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now