Using DocumentBuilder

Apologies for asking this question.

First Question:

How do I use the Document Builder to open an XML document?

Document xmlMessage;

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();

domFactory.setNamespaceAware(true);

DocumentBuilder builder = domFactory.newDocumentBuilder();

Document doc = builder.parse("books.xml");//?

I need to pass xmlMessage to the parse method() ?

how can I pass document xmlMessage?

[584 byte] By [bhuru_luthriaa] at [2007-11-27 5:24:04]
# 1
The parse method is overloaded so that you can use many different sources for your XML data. If you want to parse the content of an xml file, I suggest you use Document doc = builder.parse(new File("books.xml"));
Dalzhima at 2007-7-12 11:50:15 > top of Java-index,Java Essentials,Java Programming...
# 2

@OP: You come here quite a lot with questions about XML, several weeks apart. I'm not saying "don't do that" at all, because of course it is up to you. But I would urge you to invest in a good Java XML book, it will save you an enormous amount of pain and waiting around. I'd recommend [url=http://www.amazon.co.uk/Java-XML-Brett-D-McLaughlin/dp/059610149X/ref=pd_bbs_1/203-1708115-9526359?ie=UTF8&s=books&qid=1180017901&sr=8-1]this one[/url], but others may have better recommendations

Just a suggestion, don't take offence

georgemca at 2007-7-12 11:50:15 > top of Java-index,Java Essentials,Java Programming...