File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes create a TXElement and get a TXText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply locked New topic
Author

create a TXElement and get a TXText

Barbara Foute Nelong
Greenhorn

Joined: Nov 30, 2000
Posts: 20
Hello everyone,
can anybody shed light on my problem?
I create an xml document with the ibm parser, I print the result to the console and I get:
<application>
<type>
<number/>
<kind/>
</type>
<client>
<demo>
<first_name/>
<last_name/>
<salutation/>
<age/>
<marital_status/>
</demo>
</client>
</application>
wich is exactly the data structure I want. I save it to a file.
Now I want to get the file, parse it and loop through the nodes to get to a specific node.
code:
NonValidatingTXDOMParser parser = new NonValidatingTXDOMParser();
parser.parse(new InputSource(xml));
doc = (com.ibm.xml.parser.TXDocument)parser.getDocument();
now I want to find the element "type" in my datastructure and visit its children:
for(Node node=doc.getDocumentElement().getFirstChild();
node!=null;
node.getNextSibling()){
if(node.getNodeName().equalsIgnoreCase("type")){.....}
I cannot get pass this point because the node.getNodeName always returns "#text".
A system.out.println(node) reveals that the parser see the element (that I have created as TXElement) as a TXtext...
Anybody knows why?
Any way around it?

[This message has been edited by Barbara Foute Nelong (edited July 08, 2001).]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Asked and answered here.


"I'm not back." - Bill Harding, Twister
 
Consider Paul's rocket mass heater.
 
subject: create a TXElement and get a TXText
 
Similar Threads
is the DOM representation right???
DOMParser problem
help!Urgent,my assignment.....
JSP and XML - Need your help
a ReadXMLFile Servlet works without my expectation...