472,348 Members | 1,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Perl XPath : How to get the value of the attribute?

Hi,

I have the following XML :

<checkIn bug="1111111">
<regression>
</regression>
</checkIn>

How do i get the value "1111111" for bug ?

I am able to get everything under <checkIn> using

my $bug = $xPath->find("/checkIn[\@bug]");

TIA
--

Abhinav
Jul 20 '05 #1
4 45745


Abhinav wrote:

I have the following XML :

<checkIn bug="1111111">
<regression>
</regression>
</checkIn>

How do i get the value "1111111" for bug ?

I am able to get everything under <checkIn> using

my $bug = $xPath->find("/checkIn[\@bug]");


I don't use Perl, but the XPath should be
/checkIn/@bug

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin Honnen wrote:

Abhinav wrote:
I have the following XML :

<checkIn bug="1111111">
<regression>
</regression>
</checkIn>

How do i get the value "1111111" for bug ?

I am able to get everything under <checkIn> using

my $bug = $xPath->find("/checkIn[\@bug]");

I don't use Perl, but the XPath should be
/checkIn/@bug


Thanks. That Worked !

I guess the extra / allows me to fetch only the node containing the
attribute ?

Any docs (apart from the CPAN XPath docs) which detail these concepts more
clearly ?

TIA

--

Abhinav
Jul 20 '05 #3
Abhinav wrote:

Any docs (apart from the CPAN XPath docs) which detail these concepts
more clearly ?
Google is your friend :

http://www.w3schools.com/xpath/default.asp

And the official W3C reccomendation :

http://www.w3.org/TR/xpath

Franck,e-

TIA

--

Abhinav

Jul 20 '05 #4


Abhinav wrote:
Martin Honnen wrote:

Abhinav wrote:
I have the following XML :

<checkIn bug="1111111">
<regression>
</regression>
</checkIn>

How do i get the value "1111111" for bug ?

I am able to get everything under <checkIn> using

my $bug = $xPath->find("/checkIn[\@bug]");
I don't use Perl, but the XPath should be
/checkIn/@bug


I guess the extra / allows me to fetch only the node containing the
attribute ?


No, it selects the attribute node itself,
/checkIn
selects the <checkIn> root element,
/checkIn/@*
selects all its attribute nodes, and
/checkIn/@bug
selects the attribute with name bug
Any docs (apart from the CPAN XPath docs) which detail these concepts
more clearly ?


There is the XPath 1.0 specification:
http://www.w3.org/TR/xpath
And there are tutorials, see
http://www.w3schools.com/xpath/default.asp
for instance.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #5

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for...
1
by: Alastair Cameron | last post by:
VB6, MSXML 3.2 installed: Q1. I am having a problem selecting nodes with XPATH expressions when an attribute values contain backslashes (\\)...
9
by: Iain | last post by:
I want to create an XML configuration file which might look like <REGION Name="Europe" WingDing="Blue"> <COUNTRY Name="UK" WingDing="white">...
2
by: David Gordon | last post by:
Hi Folks, I wonder if anyone can help me with the following (perhaps trivial) problem: <xml> <node name="a" type="a"/> <node name="b"...
3
by: SD | last post by:
Hi, How can i get all the nodes with attribute Name = "Publisher" or Name="Administrator" using XPath query and C# for this xml doc? ...
2
by: akhilak | last post by:
Hi, I am using XPath to retrieve the node data from an XML file. I used the following code to extract the attribute data from the file. I manually...
4
by: paragpdoke | last post by:
Hello Perl Experts. I am new to perl and seek help with some XML stuff. My XML document is nested a few levels deep...so I want to use xpath to...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.