473,506 Members | 9,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help me with this XPath expression

Hi,
I have a xml file like this
<tab>
<category name="Software" > Test purpose
<subcategory name="Software">
<method url="addSoftware.aspx">Add</method>
<method url="editSoftware.aspx">Edit</method>
<method url="searchSoftware.aspx">Search</method>
</subcategory>
</category>
</tab>

Yesterday I asked a question about getting a node which has a specific child
node. However I realised that I need to get a node with a specific name and
has a specific child node as well. (e.g. a node's name is software and the
child node's name is software too)

I tried:
/tab/category[@name='software' and subcategory[@name='Software']]

But it did not give me any thing.

Would someone tell me the right way to do it?

Many Thanks

--
hello, please help
Nov 12 '05 #1
2 981
for an xml document like below:
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<data>
<tab>
<category name="Software" > Test purpose
<subcategory name="Software3">
<method url="addSoftware.aspx">Add</method>
<method url="editSoftware.aspx">Edit</method>
<method url="searchSoftware.aspx">Search</method>
</subcategory>
</category>
</tab>
<tab>
<category name="Software" > Test purpose
<subcategory name="Software5">
<method url="addSoftware.aspx">Add</method>
<method url="editSoftware.aspx">Edit</method>
<method url="searchSoftware.aspx">Search</method>
</subcategory>
</category>
</tab>
<tab>
<category name="Software2" > Test purpose
<subcategory name="Software2">
<method url="addSoftware2.aspx">Add</method>
<method url="editSoftware2.aspx">Edit</method>
<method url="searchSoftware2.aspx">Search</method>
</subcategory>
</category>
</tab>
</data>
to select node which category is "Software" and subcategory is "Software3"
/data/tab/category[@name="Software"]/subcategory[@name="Software3"]

"jerry.xuddd" <je********@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Hi,
I have a xml file like this
<tab>
<category name="Software" > Test purpose
<subcategory name="Software">
<method url="addSoftware.aspx">Add</method>
<method url="editSoftware.aspx">Edit</method>
<method url="searchSoftware.aspx">Search</method>
</subcategory>
</category>
</tab>

Yesterday I asked a question about getting a node which has a specific
child
node. However I realised that I need to get a node with a specific name
and
has a specific child node as well. (e.g. a node's name is software and the
child node's name is software too)

I tried:
/tab/category[@name='software' and subcategory[@name='Software']]

But it did not give me any thing.

Would someone tell me the right way to do it?

Many Thanks

--
hello, please help

Nov 12 '05 #2
jerry.xuddd wrote:
Hi,
I have a xml file like this
<tab>
<category name="Software" > Test purpose
<subcategory name="Software">
<method url="addSoftware.aspx">Add</method>
<method url="editSoftware.aspx">Edit</method>
<method url="searchSoftware.aspx">Search</method>
</subcategory>
</category>
</tab>

Yesterday I asked a question about getting a node which has a specific
child node. However I realised that I need to get a node with a specific
name and has a specific child node as well. (e.g. a node's name is
software and the child node's name is software too)

I tried:
/tab/category[@name='software' and subcategory[@name='Software']]

But it did not give me any thing.


/tab/category[@name='software'][subcategory[@name='Software']]

///Peter

Nov 12 '05 #3

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

Similar topics

1
1646
by: Phoebian | last post by:
Hi all, Here is a little concept problem, and I need some guideline. I am currently developing a application which delivers XML files. I want then to sequentially perform some actions on...
2
7359
by: GIMME | last post by:
For starters .... If : //input is the xpath syntax to see if an element with an attribute named start_date exists ... Then what is the xpath syntax to return elements having
7
1796
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
1
1658
by: Marek Mänd | last post by:
<style> .marek{} </style> etc.. <root> <element class="marek mand"/> <element class="mand marek blah"/> <element class="mand marekmänd"/> <element class="mand marekk"/> </root>
2
1496
by: Steve Jorgensen | last post by:
Working with the DOM (specifically, the MSXML DOM), I'm wondering if there's an efficient way to check whether it would be matched by a given XPath expression. I've made it work to just run the...
2
1766
by: Arthur Dzhelali | last post by:
I have a two xml files schema is identical. When I read file into dataset and then bind dataset to the form. These are weather files we are getting from weather service. One file has only...
1
3976
by: Dave | last post by:
Is it possible to get <codes><code id="4"><name>abc</name></code></codes from the XML below in single SelectSingleNode/xPath expression step OR is going to have to be a multi=step process of...
9
2128
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
3
1869
by: abcd_68 | last post by:
Hi there, I'm using, for the first time, the JDK1.5 Xpath API. I need to find elements in a Hibernate-generated .hbm.xml file. These files come with a <!DOCTYPE header mentioning a remote URL....
4
9100
by: syed.akhlaq | last post by:
Hi, Does anyone know how can I validate XPath expressions using xsd schema? Thanks
0
7220
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,...
0
7371
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...
1
7023
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
5617
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
3188
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
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
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
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
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.