473,322 Members | 1,719 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,322 software developers and data experts.

xpath syntax

I have the following xml:

<?xml version="1.0" ?>
<course>
<globalProperties>
<externalMetadata>
<source>ADL</source>
<model>ADL SCORM 1.0</model>
</externalMetadata>
</globalProperties>
<block id="B1">
<identification>
<title>Yes/No Questions</title>
<description>This course has one lesson</description>
<labels>
<curricular>MODULE</curricular>
<developer>Me</developer>
</labels>
</identification>
<au id="A100001">
<externalMetadata>
<source>ADL</source>
<model>ADL SCORM 1.0</model>
</externalMetadata>
<identification>
<title>What is yes/no question</title>
<description>This slide describes the type of the question</description>
<labels>
<curricular>AU</curricular>
<developer>Me</developer>
</labels>
</identification>
<launch>
<location>slide1.htm</location>
</launch>
</au>
<au id="A100002">
<externalMetadata>
<source>ADL</source>
<model>ADL SCORM 1.0</model>
</externalMetadata>
<identification>
<title>Examples of yes/no questions</title>
<description>This slide provide examples</description>
<labels>
<curricular>AU</curricular>
<developer>Me</developer>
</labels>
</identification>
<launch>
<location>slide2.htm</location>
</launch>
</au>
<au id="A100003">
<externalMetadata>
<source>ADL</source>
<model>ADL SCORM 1.0</model>
</externalMetadata>
<identification>
<title>Test yourself</title>
<description>This slide checks what you have learned</description>
<labels>
<curricular>AU</curricular>
<developer>Me</developer>
</labels>
</identification>
<launch>
<location>slide3.htm</location>
</launch>
</au>
</block>
<block id="B2">
<identification>
<title>WH Questions</title>
<description>This course has one lesson</description>
<labels>
<curricular>MODULE</curricular>
<developer>Me</developer>
</labels>
</identification>
</block>
<block id="B3">
<identification>
<title>Other Question Types</title>
<description>This course has one lesson</description>
<labels>
<curricular>MODULE</curricular>
<developer>Me</developer>
</labels>
</identification>
</block>
</course>

I'm trying to build a treeview that will show hierarchically the MODULEs and
the AUs. In the text of the tree nodes I want to show the title od each
identification. to get the Modules title I was trying the following xpath:
"//identification/labels[curricular='MODULE']/..title"
When running winform in c#, this expression returns me the error:
//identification/labels[curricular='MODULE']/..title has an invalid token.
Just for the test, if I try to get the developer - which is at the same
level of the label: "//identification/labels[curricular='MODULE']/developer"
- it works - I get the titles as required. How can I get the title which is
one level higher then the one I'm at?

Thanks a lot
May 24 '06 #1
3 4222
> I'm trying to build a treeview that will show hierarchically the MODULEs and
the AUs. In the text of the tree nodes I want to show the title od each
identification. to get the Modules title I was trying the following xpath:
"//identification/labels[curricular='MODULE']/..title"
When running winform in c#, this expression returns me the error:
//identification/labels[curricular='MODULE']/..title has an invalid token.
Just for the test, if I try to get the developer - which is at the same
level of the label: "//identification/labels[curricular='MODULE']/developer"
- it works - I get the titles as required. How can I get the title which is
one level higher then the one I'm at?

Thanks a lot

I dont know if it is a typo or not, but shouldnt the XPATH be
"//identification/labels[curricular='MODULE']../title"

May 24 '06 #2
It was a typo, I'm still getting the same error.

Thanks

"Dhanvanth" wrote:
I'm trying to build a treeview that will show hierarchically the MODULEs and
the AUs. In the text of the tree nodes I want to show the title od each
identification. to get the Modules title I was trying the following xpath:
"//identification/labels[curricular='MODULE']/..title"
When running winform in c#, this expression returns me the error:
//identification/labels[curricular='MODULE']/..title has an invalid token.
Just for the test, if I try to get the developer - which is at the same
level of the label: "//identification/labels[curricular='MODULE']/developer"
- it works - I get the titles as required. How can I get the title which is
one level higher then the one I'm at?

Thanks a lot

I dont know if it is a typo or not, but shouldnt the XPATH be
"//identification/labels[curricular='MODULE']../title"

May 25 '06 #3
Found it, it has to be: "//identification/labels[curricular='MODULE']/../title"

Thanks

"orit" wrote:
It was a typo, I'm still getting the same error.

Thanks

"Dhanvanth" wrote:
I'm trying to build a treeview that will show hierarchically the MODULEs and
the AUs. In the text of the tree nodes I want to show the title od each
identification. to get the Modules title I was trying the following xpath:
"//identification/labels[curricular='MODULE']/..title"
When running winform in c#, this expression returns me the error:
//identification/labels[curricular='MODULE']/..title has an invalid token.
Just for the test, if I try to get the developer - which is at the same
level of the label: "//identification/labels[curricular='MODULE']/developer"
- it works - I get the titles as required. How can I get the title which is
one level higher then the one I'm at?

Thanks a lot

I dont know if it is a typo or not, but shouldnt the XPATH be
"//identification/labels[curricular='MODULE']../title"

May 25 '06 #4

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

Similar topics

0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
2
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
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
1
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
by: Franck | last post by:
Hi, Tryin to fill range with xml data like this in my Excel Addin '1. Add Schema oExcel.ActiveWorkbook.XmlMaps.Add(tmpDs.GetXmlSchema, oRootElement) '2. Map fields...
9
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...
6
by: Gale | last post by:
I'm working on something in jQuery with XPath What I want to do is: if checkbox is checked, set background color od label that contain input(checkbox) to red I have this code:...
2
by: redcic | last post by:
Hi all, I would like to build a xml file using Xerces. I know how to build a single node at a time. For example, with 'doc' belonging to the DocumentImpl class and with 'docRootNode' belonging...
2
by: arunairs | last post by:
Hi, Is there a way of validating and XPath? In this case , I am accepting an XPath from the user and I need to validate the XPath syntax. Is there a regular expression available that anyone can...
14
by: Mikhail Teterin | last post by:
Hello! What's would be the syntax for a query, which would allow me to get only the elements with non-empty text-nodes? For example, from: <a><b></b></a> <c/> <d><e>meow</e></d>
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.