This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes xml parsing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml parsing" Watch "xml parsing" New topic

xml parsing

rupa kalid

Joined: Jul 26, 2000
Posts: 4
my problem lies in parsing......
an eg of the xml i am trying to parse is

tO parse this file and store the nodes in an array
i use the folloewing code
import org.w3c.dom.*;
public class correct
public static void main(String args[])
String s3[]=null;
String filename = "c:\\my documents\\rupac.xml";
if (filename != null) {
InputStream is;
try {
is = new FileInputStream(filename);}
catch (FileNotFoundException notFound) {

//*** The doc is the root of the DOM Tree. It is of type
//*** TXDocument which implements the DOM Document interface. p = new;
TXDocument doc = p.readStream(is);
//get the root element for this document
TXElement root = (TXElement)doc.getDocumentElement();
public static void printNodes(Node root)
NodeList n1 =root.getChildNodes();
int j=n1.getLength();
String[]s3= new String [j];
String s2=null;
for(int i=0;i<n1.getLength();i++)
if (!n1.item(i).getNodeName().equal("#text"))

System.out.println("The node is " + n1.(i).getNodeName() + " value " + n1.item(i).getNodeValue());
when i do this i get....node is #text....along with the correct nodes......
why do i get #text when there is no #text in my xml
and if i try to remove
these lines of code....then i get rid of #text but all my node values are null
please help
Rama Raju

Joined: Jul 07, 2000
Posts: 12
Hi Rupa,
The xml file written is not well formed. Why don't u write well formed xml and then try.
I agree. Here's the link:
subject: xml parsing
jQuery in Action, 3rd edition