473,499 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Xpath question; retrieve attributes for specific parent

2 New Member
I have an xml file that looks like this:

<DocBuild name="ABC">
<BldArea name="Components" product="ABC" area="C">
<BldItem name="Item1" module="mod1" tier="A" buildtype="auto"/>
<BldItem name="Item2" module="mod2" tier="B" buildtype="auto"/>
</BldArea>
<BldArea name="Core" product="ABC" area="C">
<BldItem name="Item5" module="mod5" tier="A" buildtype="auto"/>
<BldItem name="Item6" module="mod6" tier="B" buildtype="auto"/>
</BldArea>
</DocBuild>

I want to retrieve the name and tier attributes for BldItem elements whose BldArea is "Components". To get both attributes I can use something like BldItem/@name|BldItem/@tier but how do I specify that I just want those under 'Components'? There will be only one BldArea that contains name="Components" in the actual XML file.
Jul 1 '08 #1
2 2615
jkmyoung
2,057 Recognized Expert Top Contributor
BidArea[@name = 'Components']/BldItem/@name | BidArea[@name = 'Components']/BldItem/@tier

or depending on context perhaps:
(BldItem/@name|BldItem/@tier)[../../@name='Components']
Jul 2 '08 #2
samsquared
2 New Member
Thank you - that did it! (I didn't try your second suggestion.)
Jul 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2359
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...
1
1999
by: Brad Hehe | last post by:
I am attempting to use XPath to query for a specific node in the sample XML I've provided below. I'm unsure of the exact XPath syntax, but I believe I need the following query to get the proper...
0
1365
by: Paw Pedersen | last post by:
I have a XSD loaded into a XmlSchema class. I need to retrieve the attribut names for/under a specific node in this schema, and I have the full xpath for the node in the schema. How do I do this?...
6
15479
by: Chua Wen Ching | last post by:
Hi there, I had this xml file with me (not yet consider implementing xml namespaces yet). <?xml version='1.0'?> <Object> <Windows> <EID>1</EID> <EDesc>Error 1</EDesc> </Windows>
10
2269
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...
4
1480
by: cgaden | last post by:
Hi everyone, I have a problem that I've been trying to figure out for a while but I just can't seem to get it right. I have the following XML fragment: <Page ID="x1" Schema="Folder"> -<Page...
2
1643
by: Yarik | last post by:
Hello, I am not sure the subject of my post adequately describes the problem I am trying to solve, so I think a specific example would be helpful. Let's say there are XML descriptions of...
6
1997
by: Derek Hart | last post by:
I bring in an xml file into vb.net by using xmlDoc.LoadXml(XMLString) - I run xpath statements against the xml file to grab data from it, so I use, as an example, //Vehicles/Vehicles/@make to get...
0
7007
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
7171
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
7220
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
5468
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
4599
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
3098
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
1427
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
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
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.