Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML and Java

 
Raheel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i use java with XML. If i want to parse the xml document with java code, then how it can be possible. Please let me know, if any1 knows about this. I'm aware of java and xml as well.
regards,
Raheel.
 
Varun_Pant
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you can do is really phenomenal.
Just for example, you can send the data input by a user in a webpage as a response to an event ( as a click of a button) as a �node� to the �Solver� which is written in Java, which can then retrieve the data stored in the node using
A sample code can run thus:
public String getDatabaseValues(Node eqNode, Document doc) {
//instantiate the variables
String st = ""; String st2 = ""; String st3 = "";
NamedNodeMap nm = eqNode.getAttributes();
//
if(nm.getNamedItem("Pfs")!=null){
st1 = nm.getNamedItem("NodeName").getNodeValue();
etc�etc..
 
Varun_Pant
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DOM is the API for Document Object Model. DOM provides a representation of XML document as a tree, with data stored in the nodes: Each node representing a portion of data drawn from the original document.
Using a suitable XML parser , like Apache Xerces, one can create a DOM tree.
Refer any good book on DOM and parsing XML data.
 
jeremy crosbie
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Varun_Pant:
DOM is the API for Document Object Model. DOM provides a representation of XML document as a tree, with data stored in the nodes: Each node representing a portion of data drawn from the original document.
Using a suitable XML parser , like Apache Xerces, one can create a DOM tree.
Refer any good book on DOM and parsing XML data.

You can also look into JDOM (www.jdom.org) which provides a more Java-centric and lightweight for of XML document handling. It is much easier to use than DOM for Java development with XML.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic