473,566 Members | 2,772 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="Component s" 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="Component s" in the actual XML file.
Jul 1 '08 #1
2 2619
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='Componen ts']
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
2364
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 specific elements within my XML file. The problem I am getting is that one of the XML elements contains namespace attributes and this seems to prevent...
1
2006
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 node where the node value contains a specific value: /FYIFORM/TEMPLATEINFO/FIELD = "THE FORM I WANT"
0
1368
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? I'm not sure I should use the XmlSchema class to load the XSD. Regards Paw
6
15495
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
2276
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 field names. Everything there works fine. Here's my XML Document: <?xml version="1.0" standalone="yes" ?> <DataSet1...
4
1487
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 ID="x10" Schema="Common"> --<Page ID="x100" Schema="Common" /> --<Page ID="x200" Schema="Common" /> --<Page ID="x300" Schema="Common" />
2
1650
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 products like this one: <!-- File: Products.xml --> ... <Product id="p1">
6
2002
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 the make of the car. But then I pass a specific node from xmlDoc into another function, not the whole xmlDoc, just a node from it. And if I run an...
0
7666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7644
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
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 we have to send another system
1
1201
muto222
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.