Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.NET Webbrowser XML

Posted on 2006-07-24
10
Medium Priority
?
641 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 1000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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 …
Progress

618 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