473,511 Members | 14,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XPath Query by namespace

I'm trying to find the most efficient way to query specific nodes from an xml
document using vb.net. My app will receive various types of xml documents
and there are child nodes that will always exist that I need to retrieve data
from before processing the whole document.

There are several different root elements that can be sent, but within the
document there will always be a 'DataAreaToQuery' node. The
'DataAreaToQuery' child node will not always be the first child node off the
root; it may be two levels deep.

Ultimately what I’m looking for is to get the root element by namespace.
The namespace for 'DataAreaToQuery' will always be the same and unique to the
rest of the document.

Thanks in advance for your input.

Sample XML:
<?xml version="1.0" encoding="UTF-8"?>
<OneOfManyRootElementNames
xmlns="http://OneOfManyRootElementNames/ns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<st:DataAreaToQuery xmlns:st="http://dataareatoquery/ns">
<st:ApplicationArea>
<st:Sender>
<st:LogicalId>String</st:LogicalId>
<st:Component>String</st:Component>
<st:Task>String</st:Task>
<st:ReferenceId>String</st:ReferenceId>
<st:AuthorizationId>String</st:AuthorizationId>
<st:CreatorNameCode>String</st:CreatorNameCode>
<st:SenderNameCode>AF</st:SenderNameCode>
<st:SenderURI>http://www.altova.com</st:SenderURI>
</st:Sender>
<st:Destination>
<st:DestinationNameCode>AF</st:DestinationNameCode>
<st:DestinationURI>http://www.altova.com</st:DestinationURI>
<st:DestinationSoftwareCode>String</st:DestinationSoftwareCode>
<st:DestinationSoftware>String</st:DestinationSoftware>
</st:Destination>
</st:ApplicationArea>
</st:DataAreaToQuery>
<st:DataArea1/>
<st:DataArea2/>
<st:DataArea3/>
</OneOfManyRootElementNames>

Nov 12 '05 #1
1 1534
Clay wrote:
I'm trying to find the most efficient way to query specific nodes from an xml
document using vb.net. My app will receive various types of xml documents
and there are child nodes that will always exist that I need to retrieve data
from before processing the whole document.

There are several different root elements that can be sent, but within the
document there will always be a 'DataAreaToQuery' node. The
'DataAreaToQuery' child node will not always be the first child node off the
root; it may be two levels deep.

Ultimately what I’m looking for is to get the root element by namespace.
The namespace for 'DataAreaToQuery' will always be the same and unique to the
rest of the document.


It's just "//st:DataAreaToQuery" query (bind st prefix using
XmlNamespaceManager). Or (long form) use
//*[local-name()='DataAreaToQuery' and
namespace-uri()='http://dataareatoquery/ns']

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

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

Similar topics

1
2362
by: Chris | last post by:
Hi all, I have recently started working with the new XML functionality in PHP5, but I am running into a few problems. Specifically, I am using an Xpath query to try and pull out the data in...
6
5959
by: 0wl | last post by:
Hi, I am trying to get the value of child from xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child DataType="String">Hellpppp</p:child></p:root>""" using...
4
3024
by: MarcoT77 | last post by:
Hi Teacher. I'm trying to get with Xpath the Product nodes in the following XML: <?xml version="1.0" encoding="utf-8"?> <PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema"...
1
5787
by: Robert | last post by:
I am having a problem selecting nodes using the XMLnodelist Selectnodes using XPATH when I use XML SPY is successfully queries but when is use VB.net it comes up with nothing. Here is my code ...
2
2861
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
2
10041
by: dc | last post by:
i have a xml file like this: <?xml version="1.0" encoding="utf-8"?> <validate xmlns="http://tempuri.org/fieldValidate.xsd"> <field name="Short Name" type="SN" length="10"> <requiredChar...
10
2272
by: Michael C# | last post by:
OK, here's the deal. I have a small XML file that represents a small database table. I load it into a System.XML.XMLDocument. So far so good. I run an XPath query against it to retrieve all the...
18
7704
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
3
4959
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
3
4122
by: 0to60 | last post by:
Please help! I'm using the following code to get an XML doc: string str = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=12345&city=addison"; System.Net.HttpWebRequest request =...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.