You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Imtiyaz <im...@yahoo.co.in> on 2004/05/26 06:13:13 UTC

Re: how to separte node value from the result (Thanks)

hello Jelle sir,
 
Thanks for u r solution.
i tryed the dom4j.jar to sepearte the node values and it
is working fine. but the code u have given i have to make 
some changes in that and its working fine now.
 
the changes that i made
 
String docstr = (String) document.getContent();
   Document doc = DocumentHelper.parseText(docstr);
   System.out.println("doc id "+doc);
 
   List  list = doc.selectNodes("/notes/note[5]" );
   Iterator    iter=list.iterator();
        while(iter.hasNext()){
         Element element=(Element)iter.next();
         Iterator iterator=element.elementIterator("note");
         System.out.println(element.getText());
         }
 

regards,
imtiyaz

Jelle Alten <je...@hotmail.com> wrote:
Hi Imtiyaz,
 
This is more a Java/XML question than a Xindice question. You can google some of the words "java xml string node parse" and find some answers there.
 
This is a snippet from my code that might point you into the right direction as well:
 
            XMLResource document = (XMLResource) col.getResource(id);
            String docstr = (String) document.getContent();
            Document doc = DocumentHelper.parseText(docstr);
            Element dossier = doc.getRootElement();
            Element el1 = dossier.element("SomeNode");
            Element el2 = zitting.element("SomeSubNode");
            return el2.getText();

I import
    org.xmldb.api.modules.XMLResource
    org.dom4j.Document
    org.dom4j.Element
    org.dom4j.DocumentHelper

 
Good luck.
 
Jelle
----- Original Message ----- 
From: Imtiyaz 
To: xindice-users@xml.apache.org 
Sent: Tuesday, May 25, 2004 9:10 AM
Subject: how to separte node value from the result


hi all
 
using java programme i am writing programme which is used to
 
retrieve data from the xindice but the result are coming in a string 
 
format.  
 
 
because result are coming in a xml tag format if i just
 
want to used  node value it will not possible to me
 
then how to separte the node value ?
 
is  there any api provided for this ?
 
 
i have xml file <note> one </note>
                     <note> two </note>
                      <note> three </note>
                       <note> four </note>
 
i written the xpath query /notes/notes[2]
 
result are coming 
all the xml entry
<note> two </note>
 
but i just want answer will give me "two" in a string
 
sry for long mail
 
 
 

Yahoo! India Matrimony: Find your partner online.

Yahoo! India Matrimony: Find your partner online.