Solved

VB.NET Webbrowser XML

Posted on 2006-07-24
10
615 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
This is an explanation of a simple data model to help parse a JSON feed
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

947 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

22 Experts available now in Live!

Get 1:1 Help Now