Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

XML Doubt

  Asked By: Kelley    Date: Feb 11    Category: Java    Views: 731

I need to write a code for getting an XML file... and
get the elements attribs and values of all elements.

the program shud work for ne general file.

can ne1 help me on this?

I am making a DocumentBuilderFactory object which
makes a DocumentBuilder object which can use the parse
method to parse the file.

the parser can get the root element by using the
getDocumentElement method.

now the XML file can be nested in any way... so i need
to get the child nodes...and then see if it has ne
more child nodes etc.

can ne1 put some light on wht i need to do.
I am a novice in JAVA...



3 Answers Found

Answer #1    Answered By: Tarrant Thompson     Answered On: Feb 11

After doing this change the root  to the child  element
which u want to traverse now.
You can do this by going root.getChild(i) fununction
giving the i as the number of the child

Answer #2    Answered By: Janelle Evans     Answered On: Feb 11

Try looking for code  samples on google.
One place is:


Answer #3    Answered By: Lela Lynch     Answered On: Feb 11

I don't know if you want to write  your own code  for
reading XML files or not, but you can examples and a
good parser  with dom4j

Didn't find what you were looking for? Find more on XML Doubt Or get search suggestion and latest updates.