473,486 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

X-path namespace sample and question

I have an XML document that is structured similarly to the following
generalization:

<?xml version="1.0" encoding="UTF-8"?>
<A xmlns="urn:aaa-aaa-aaa:a-part">
<B>
<C xmlns="urn:ccc-ccc-ccc:c-part">
<D>1</D>
<D>2</D>
</C>
<C xmlns="urn:ccc-ccc-ccc:c-part">
<D>3</D>
<D>4</D>
</C>
</B>
<B>
<C xmlns="urn:ccc-ccc-ccc:c-part">
<D>5</D>
</C>
</B>
</A>

is there a simpler XPATH expression to grab all <D> elements than the
following?

//*[namespace-uri()='urn:ccc-ccc-ccc:c-part' and local-name()='D']

The problem seems to stem from the fact the the documents I am given do
not have namespace prefixes.

Any thoughts?

Thanks,
Leonard Armstrong
Jul 20 '05 #1
3 1923
In article <Xn*******************************@199.171.54.214> ,
Leonard T. Armstrong <la********@nbme.org> wrote:
is there a simpler XPATH expression to grab all <D> elements than the
following?

//*[namespace-uri()='urn:ccc-ccc-ccc:c-part' and local-name()='D']


You need to bind a prefix to the namespace in the context of your
XPath. So if it appears in a stylesheet, bind a prefix in the
stylesheet.

-- Richard
Jul 20 '05 #2
Thanks Richard, but I should have clarified that the problem is not with an
XSLT stylesheet. I recognize that in that context I can do prefix binding an
all will be well with the world.

My question stems from the use of te XPath tool in XMLSpy, where all I have
is original XML document (over which I have no control) and the XPath tool
to do some quick analysis to verify XPath expression prior to developing an
XSLT.

Thanks for the response,.
-- Leonard

"Richard Tobin" <ri*****@cogsci.ed.ac.uk> wrote in message
news:c9**********@pc-news.cogsci.ed.ac.uk...
In article <Xn*******************************@199.171.54.214> ,
Leonard T. Armstrong <la********@nbme.org> wrote:
is there a simpler XPATH expression to grab all <D> elements than the
following?

//*[namespace-uri()='urn:ccc-ccc-ccc:c-part' and local-name()='D']


You need to bind a prefix to the namespace in the context of your
XPath. So if it appears in a stylesheet, bind a prefix in the
stylesheet.

-- Richard

Jul 20 '05 #3
Leonard T. Armstrong wrote:
My question stems from the use of te XPath tool in XMLSpy, where all I have
is original XML document (over which I have no control) and the XPath tool
to do some quick analysis to verify XPath expression prior to developing an
XSLT.


You need prefixes in XPath, too. If the tool you use doesn't give you
the possibility to bind prefixes to namespaces -- which I don't know --
the tool is not applicable for your task.

[TOFU snipped]
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Jul 20 '05 #4

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

Similar topics

5
1925
by: cppaddict | last post by:
It is typical to put the line: using namespace std; at the top of a file which makes use of std library objects. To take a simple example: #include <iostream> using namespace std;
5
1904
by: studen77 | last post by:
Thanks in advance to anyone who can help :) I'm trying to extract a specific NodeSet out of an XML file; however, I'd like to include a C# string variable as part of the XPATH statement; so far...
1
1426
by: chriscorbell | last post by:
I'm fairly new to XSLT and XPath. My question is related to some posts I found in group archives (e.g. "Disable XPath namespace matching in XSL") but is a little more specific. I want a single...
0
904
by: Sabba | last post by:
TESTRESULTS PRE STUDENT @sID=1 @Score=5 STUDENT @sID=2 @Score=2 STUDENT @sID=3
2
4437
by: Tony Girgenti | last post by:
Hello. I'm developing a web comsuming client using VS.NET 2003(VB), .NET Framework 1.1.4322, ASP.NET 1.1.4322, WSE2.0 on a WinXP Pro Sp2 computer. I'm getting an XML document this way: Dim...
2
3592
by: =?Utf-8?B?Q2h1Y2sgUA==?= | last post by:
I am trying to retrieve the @AnswerCount Attribute for the @QuestionID=1 AND the Answer element text =3 I successfully can pass the variables QuestionID and Answer but can't pull out the...
2
2064
by: ranadhirnag | last post by:
We have an xml viz. <element> <component>....</component> <event>....</event> <event>....</event> <event>....</event> <event>....</event> </element> The number of events will be dynamic.
3
8434
by: Markus Bauer | last post by:
Hello, I have a problem with the namespace prefix. I need to add nodes to a xml file that is not created by me. It has a namespace with the prefix "NFD". So an already existing node looks...
1
927
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I haven't made all that much use of 'Namespace' but I thought I understood it. I'm in the process of translating a C# project to VB. (Dot Net 2.0) In the program I'm working on now, I have a...
0
7173
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
7305
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
5427
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,...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3066
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
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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 ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.