xPATH PROBLEM

View: New views
2 Messages — Rating Filter:   Alert me  

xPATH PROBLEM

by Ven Helsing :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear All,

I am facing a problem in setting the xpath for a simplexmlextractor. My xml file structure is as below.

<Q>
      <question>
                   <ques answer="india" output="screen">
      </question>
      <question>
                   <ques answer="russia" output="plotter">
      </question>
      <question>
                   <ques answer="china" output="printer">
      </question>
</Q>

i want to make proterteis to answer and output. how to set xpath.

<instruction property="answer" xpath="/Q/question/ques/answer" />
<instruction property="output" xpath="/Q/question/ques/output" />


OR

<instruction property="answer" xpath="/Q/question/ques" />



Help required plz.




Parent Message unknown RE: xPATH PROBLEM

by Jeroen Reijn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Aslam,

this is more an xpath expression then a slide question I guess, but your XPATH will need be this:

<instruction property="answer" xpath="/Q/question/ques/@answer" />
<instruction property="output" xpath="/Q/question/ques/@output" />

I have to remind you though that this will not extract multiple occurences of the question xpath, since the values are stored within an attribute of the node, so you will get the first result only inside you extracted property. Which is in this case 'india' and 'screen'.

According to the documentation inside the source code it should work on text nodes.

http://svn.apache.org/repos/asf/jakarta/slide/trunk/src/share/org/apache/slide/extractor/SimpleXmlExtractor.java

Another solution is that you could use a different extractor or a custom one. For Hippo Repository [1] (a content repository based on Slide) we created several new extractors. There is multivalueXMLProperty extractor which you could use in this case. It extracts all values comma seperated into a single value.

Kind regards,

Jeroen Reijn

[1] http://wiki.hippo.nl/display/CMS/Hippo+Repository+v1.2.x+Documentation

-----Original Message-----
From: Aslam Bari [mailto:iamaslamok@...]
Sent: zaterdag 30 september 2006 8:44
To: slide-user@...
Subject: xPATH PROBLEM



Dear All,

I am facing a problem in setting the xpath for a simplexmlextractor. My xml
file structure is as below.

<Q>
      <question>
                   <ques answer="india" output="screen">
      </question>
      <question>
                   <ques answer="russia" output="plotter">
      </question>
      <question>
                   <ques answer="china" output="printer">
      </question>
</Q>

i want to make proterteis to answer and output. how to set xpath.

<instruction property="answer" xpath="/Q/question/ques/answer" />
<instruction property="output" xpath="/Q/question/ques/output" />


OR

<instruction property="answer" xpath="/Q/question/ques" />



Help required plz.




--
View this message in context: http://www.nabble.com/xPATH-PROBLEM-tf2360660.html#a6576608
Sent from the Jakarta Slide - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@...
For additional commands, e-mail: slide-user-help@...


---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@...
For additional commands, e-mail: slide-user-help@...

LightInTheBox - Buy quality products at wholesale price!