473,378 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

XMLDocument Parsing Issue in VB.NET

Hi,

I am trying to parse a xmldocument and to get value of a name tag
"techlanguage" is "vbdotnet".

Here i need to select the propername tag which is "techlanguage" and
the propervalue which is "vbdotnet"

Here is the structure of my XML

<?xml version="1.0" encoding="utf-8" ?>
<filters>
<filter customFilterType="">
<name>techdatabase</name>
<value>sqlserver</value>
</filter>
<filter customFilterType="">
<name>techlanguage</name>
<value>vbdotnet</value>
</filter>
<filter customFilterType="">
<name>techjava</name>
<value>j2ee</value>
</filter>
</filters>

Here is the code that tries to get the techlanguage as vbdotnet

Dim XMLValidateDoc As New XmlDocument
Dim Selectedtechlanguage As
System.Xml.XmlNode
Dim techlanguage As String
Try
XMLValidateDoc.Load(New
StringReader(Me.ucFilterSelector1.FilterXML.ToStri ng()))
Selectedtechlanguage =
XMLValidateDoc.SelectSingleNode("///name[@name=techlanguage ]")
If Not Selectedtechlanguage Is Nothing
Then
'here i need to assign vbdotnet as
the techlanguage
' techlanguage = "vbdotnet" this is
what i exactly want
techlanguage =
Selectedtechlanguage.InnerText
End If

' bla bla

What is exact XPATH query i need to make to get the techlanguage valus
which is vbdotnet.please let me know what is the right code to do
this..

thanks
satish

Jan 12 '07 #1
2 3555

rajesh wrote:
Hi,

I am trying to parse a xmldocument and to get value of a name tag
"techlanguage" is "vbdotnet".

Here i need to select the propername tag which is "techlanguage" and
the propervalue which is "vbdotnet"

Here is the structure of my XML

<?xml version="1.0" encoding="utf-8" ?>
<filters>
<filter customFilterType="">
<name>techdatabase</name>
<value>sqlserver</value>
</filter>
<filter customFilterType="">
<name>techlanguage</name>
<value>vbdotnet</value>
</filter>
<filter customFilterType="">
<name>techjava</name>
<value>j2ee</value>
</filter>
</filters>

Here is the code that tries to get the techlanguage as vbdotnet

Dim XMLValidateDoc As New XmlDocument
Dim Selectedtechlanguage As
System.Xml.XmlNode
Dim techlanguage As String
Try
XMLValidateDoc.Load(New
StringReader(Me.ucFilterSelector1.FilterXML.ToStri ng()))
Selectedtechlanguage =
XMLValidateDoc.SelectSingleNode("///name[@name=techlanguage ]")
If Not Selectedtechlanguage Is Nothing
Then
'here i need to assign vbdotnet as
the techlanguage
' techlanguage = "vbdotnet" this is
what i exactly want
techlanguage =
Selectedtechlanguage.InnerText
End If

' bla bla

What is exact XPATH query i need to make to get the techlanguage valus
which is vbdotnet.please let me know what is the right code to do
this..

thanks
satish
I think you are going to have to do a SelectNodes call on the filters
node list, and then do a SelectSingleNode from that list specifing
"filter/name" and "filter/value" to get the values out for them. But in
your case, you would need to do a For Each on the node list, get each
one, and look for the value of "filter/name" to see if you are on the
right one to retreive the "filter/value" for.

Jan 12 '07 #2
satish,

This will select the filter tags that have a 'name' child node with a value
of 'techlanguage' and a 'value' child node with a value of 'vbdotnet'

SelectSingleNode("filters/filter[name='techlanguage' and value='vbdotnet']

Below you are asking - SelectSingleNode("///name[@name=techlanguage ]").

This is asking for all nodes of 'name' node that have an attributed named
'name' with a value of 'techlanguage'. This does not exist in your
document.

rick


"rajesh" <te********@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Hi,

I am trying to parse a xmldocument and to get value of a name tag
"techlanguage" is "vbdotnet".

Here i need to select the propername tag which is "techlanguage" and
the propervalue which is "vbdotnet"

Here is the structure of my XML

<?xml version="1.0" encoding="utf-8" ?>
<filters>
<filter customFilterType="">
<name>techdatabase</name>
<value>sqlserver</value>
</filter>
<filter customFilterType="">
<name>techlanguage</name>
<value>vbdotnet</value>
</filter>
<filter customFilterType="">
<name>techjava</name>
<value>j2ee</value>
</filter>
</filters>

Here is the code that tries to get the techlanguage as vbdotnet

Dim XMLValidateDoc As New XmlDocument
Dim Selectedtechlanguage As
System.Xml.XmlNode
Dim techlanguage As String
Try
XMLValidateDoc.Load(New
StringReader(Me.ucFilterSelector1.FilterXML.ToStri ng()))
Selectedtechlanguage =
XMLValidateDoc.SelectSingleNode("///name[@name=techlanguage ]")
If Not Selectedtechlanguage Is Nothing
Then
'here i need to assign vbdotnet as
the techlanguage
' techlanguage = "vbdotnet" this is
what i exactly want
techlanguage =
Selectedtechlanguage.InnerText
End If

' bla bla

What is exact XPATH query i need to make to get the techlanguage valus
which is vbdotnet.please let me know what is the right code to do
this..

thanks
satish

Jan 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Omkar Singh | last post by:
I try to parse a XML document containg some references using XmlDocument Class' method GetElementbyTagName. It just give the content between starting tagName and ending tagName but not all...
1
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid...
13
by: Matthew Wieder | last post by:
In my C# application, I have class which has method that opens an XML document, modifies it and saves it out. I run that method for several different XML documents. What I've found is that the...
1
by: RiceGuy | last post by:
Hi, I'm wondering on how to go about writing a simple XML parser, one that doesn't use the XmlDocument class (DOM API) and relies only on (in-built, so to say low-level) file system and string...
7
by: Mark | last post by:
Hi... A colleague just referred this question to me. He's getting an xml file from another party, which he's trying to process into another dom using an XmlTextReader and...
1
by: Peter Nofelt | last post by:
Hey All, I'm running into this issue with parsing through an xml document by tag name. Below is an example xml document: File Name: things.xml <things> <people> <name>Peter</name>
4
by: David Grogan | last post by:
Hi, 2 questions.... 1. I'm parsing an XHTML document that contains both the default namespace (xmlns="http://www.w3.org/1999/xhtml") and a custom one (xmlns:r="...") - both of these being...
2
by: Phil Galey | last post by:
I'm using the followg code to add the attribute overwrite='true" to a select list of XML tags in an XML document. The document is loaded from a file and just the tags with names matching what's in...
1
by: rajesh | last post by:
Hi, I am trying to parse a xmldocument and to get value of a name tag "techlanguage" is "vbdotnet". Here i need to select the propername tag which is "techlanguage" and the propervalue...
3
MrMancunian
by: MrMancunian | last post by:
Hi, I've created an HTTP connection with a server. I send a WebRequest in XML to the server (see strReq in code) and it returns me a WebResponse. This response is inserted in a string, which is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.