I was a bit to hurry.  In fact it works only for the first child.

I tried the code in the JavaDoc but page is null.
:-(

This is my code.

public static NodeList convertXMLtoNodeList(XML theXML) throws Exception
{
 PI p = new PI();
 p.setVersion(1.0);
 p.addElement(theXML);
 DOMFactory d = new DOMFactory();
 p.output(d.getOutputStream());
 NodeList nl = d.createDOM();
 return nl;
}

public static void main(String[] args)
{
 XML x = new XML("root", true);
 XML x1 = new XML("page", true);
 XML x2 = new XML("paragraph");
 XML x3 = new XML("paragraph");
 x2.addElement("This is the first Paragraph");
 x3.addElement("This is the second Paragraph");
 x.addElement(x1.addElement(x2).addElement(x3));
 try
 {
  NodeList nl = convertXMLtoNodeList(x);
  org.w3c.dom.Node root = nl.item(1);;
  org.w3c.dom.Node page = root.getFirstChild();
  org.w3c.dom.Node paragraph1 = page.getFirstChild();
  String text = paragraph1.getNodeValue();
   }
 catch (Exception e)
 {
  e.printStackTrace();
 }
}

Is there something I do wrong ??
Any idea ??

Herv�

----- Original Message -----
From: Herv� Guidetti
To: ECS
Sent: Tuesday, December 05, 2000 5:50 PM
Subject: Re: How to transform XML to org.w3c.Document


Ooooooooooh yes,
It works.
Thanks a lot
:-))

Herv�

----- Original Message -----
From: Stephan Nagy
To: ECS
Sent: Tuesday, December 05, 2000 4:45 PM
Subject: Re: How to transform XML to org.w3c.Document


Use the org.apache.ecs.factory.DOMFactory it requires xerces to be installed
and in the classpath but it will do the trick.

-stephan

Herv� Guidetti wrote:

Hi,

I want to use ecs to create an XML tree (using the XML class).
After creating this tree, I want to parse it.

In fact, I need to transfom the org.apache.ecs.xml.XML to a
org.w3c.Document.

Do you have an idea how to do this ?

Thanks,

Herv�



--
------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to