473,661 Members | 2,506 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="addSoftwar e.aspx">Add</method>
<method url="editSoftwa re.aspx">Edit</method>
<method url="searchSoft ware.aspx">Sear ch</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 991
for an xml document like below:
<?xml version = "1.0" encoding="Windo ws-1252" standalone="yes "?>
<data>
<tab>
<category name="Software" > Test purpose
<subcategory name="Software3 ">
<method url="addSoftwar e.aspx">Add</method>
<method url="editSoftwa re.aspx">Edit</method>
<method url="searchSoft ware.aspx">Sear ch</method>
</subcategory>
</category>
</tab>
<tab>
<category name="Software" > Test purpose
<subcategory name="Software5 ">
<method url="addSoftwar e.aspx">Add</method>
<method url="editSoftwa re.aspx">Edit</method>
<method url="searchSoft ware.aspx">Sear ch</method>
</subcategory>
</category>
</tab>
<tab>
<category name="Software2 " > Test purpose
<subcategory name="Software2 ">
<method url="addSoftwar e2.aspx">Add</method>
<method url="editSoftwa re2.aspx">Edit</method>
<method url="searchSoft ware2.aspx">Sea rch</method>
</subcategory>
</category>
</tab>
</data>
to select node which category is "Software" and subcategory is "Software3"
/data/tab/category[@name="Software "]/subcategory[@name="Software 3"]

"jerry.xudd d" <je********@dis cussions.micros oft.com> wrote in message
news:91******** *************** ***********@mic rosoft.com...
Hi,
I have a xml file like this
<tab>
<category name="Software" > Test purpose
<subcategory name="Software" >
<method url="addSoftwar e.aspx">Add</method>
<method url="editSoftwa re.aspx">Edit</method>
<method url="searchSoft ware.aspx">Sear ch</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="addSoftwar e.aspx">Add</method>
<method url="editSoftwa re.aspx">Edit</method>
<method url="searchSoft ware.aspx">Sear ch</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
1660
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 selected part of that XML file through a XPath expression. These action have actually to modify the structure of the XML file itself and that seems to me like a big hurdle. Maybe I am wrong but I will try to explain what I want to do...
2
7371
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
1805
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"; XmlElement crsElement = (XmlElement)m_colorRangeSwatchDoc.SelectSingleNode(expr); bool fr = bool.Parse(crsElement.GetAttribute("fixed").ToString()); The element returned is always the 1st, All Blue Colors, why doesn't the expression...
1
1665
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
1506
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 XPath select on the document, looping through all the nodes returned, and seeing if one of those is the same as the node in question. If I need to check many expressions, though, this would not be efficient.
2
1775
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 local weather so I don't have any problems with that, but other has weather for several different locations. Basically I need to select only weather for location if I know its code. I should have exactly same dataset so I will be able bind it to the...
1
4000
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 using SelectNodes with an XPath expression to return all the nodes with "code id = 4", iterate the NodeList, re-build the XML string and wrap it with "<codes>" again? I wasn't sure if you can somehow return the parent node when using xPath to find...
9
2148
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 should work. Also the second nav.OuterXml appears to also be wrong to me. Can someone explain to me why this does not work? (This is an example from a program we have where xpath can be entered in two parts so we have to be able
3
1874
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. The Xpath parser fetches the URL from the hibernate.sourceforge site. So far so good. However, if I unplug the network, I get (after a *long* timeout) a java.net.SocketException. I looked around and I found out that I have to define a class...
4
9125
by: syed.akhlaq | last post by:
Hi, Does anyone know how can I validate XPath expressions using xsd schema? Thanks
0
8432
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8762
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5653
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.