473,396 Members | 1,936 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,396 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 45842


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 XPath features Basic paths are supported 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 (\\) in as part of its value: For example the...
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"> <TOWN Name="London" WingDing="Orange" /> </COUNTRY>...
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" type=""/> <node name="c"/> <node name="d" type="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? <GetRoleCollectionFromUser...
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 entered the attribute name in the code and I am...
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 find the exact element to work with. Then I wish to:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.