You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sukkary <Su...@imkenberg.net> on 2000/10/19 03:46:10 UTC

Document Object Handling

 Hi all,
 My main task is to traverse a Document object's DOM tree and print its TEXT
node values
 in xml file using xsp processor
 I tried to create and traverse a Document object as follows :

 <xsp:logic>

 public Document getDoc(){

  Document doc = xspParser.createEmptyDocument();
    doc.createElement("Article");
    doc.appendChild(doc.createElement("Article_No"));
    doc.createTextNode("Hello From Amin");


    return doc;
}

public String PrintArt(Document doc){
   NodeList Art = doc.getElementsByTagName("Article");
   Node node = Art.item(0);
   NodeList Art_text = node.getChildNodes();
   node = Art_text.item(0);

return node.getNodeValue();
}

</xsp:logic>

 !!!!!!........ but when i tried to present the text node's
contents..................!!!!!!
 ??????........ i surprised that cocoon raise a null pointer
exception...............???????
 which means that my created document object is empty, why?
 can any one tell me how can i create a document object that contain this
document fragment and
 present its text node contents in xml ?

Thanks,
M. Amin