[ nesja2002 @ 09.04.2005. 07:20 ] @
U svim tutorijalima stoj:
Code:

  java.io.File file = new java.io.File( filename ) ;  
 javax.xml.parsers.DocumentBuilderFactory builderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance() ;
 javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder() ;
org.w3c.dom.Document document = builder.parse( file ) ;

Sta dalje kako da procitam odredjeni Nod i child tog noda i kako da upisem izmene u *.xml
[ _owl_ @ 09.04.2005. 14:35 ] @
Pa jesi li pogledao objeasnjenja za metode koje ima Document klasa (cudo ti je Java dokumentacija -- sta sve tamo ima).
Citat:

Element getDocumentElement()
This is a convenience attribute that allows direct access to the child node that is the document element of the document.

Citat:

NodeList getElementsByTagName(String tagname)
Returns a NodeList of all the Elements in document order with a given tag name and are contained in the document.

Parameters:
tagname - The name of the tag to match on. The special value "*" matches all tags. For XML, the tagname parameter is case-sensitive, otherwise it depends on the case-sensitivity of the markup language in use.
Returns:
A new NodeList object containing all the matched Elements.

Citat:

NodeList getElementsByTagNameNS(String namespaceURI,
String localName)
Returns a NodeList of all the Elements with a given local name and namespace URI in document order.

Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements.
Since:
DOM Level 2

Citat:

Element getElementById(String elementId)
Returns the Element that has an ID attribute with the given value. If no such element exists, this returns null . If more than one element has an ID attribute with that value, what is returned is undefined.
The DOM implementation is expected to use the attribute Attr.isId to determine if an attribute is of type ID.

Note: Attributes with the name "ID" or "id" are not of type ID unless so defined.

Parameters:
elementId - The unique id value for an element.
Returns:
The matching element or null if there is none.
Since:
DOM Level 2


Sada posto si lepo procitao objasnjenje svih ovih metoda, pogledaj u dokumetaciji sta pise za klase Element i Node, pa ces onda znati kako da pristupas sadrzaju (i jos kojecemu) XML dokumenta.

Pisanje XML-a mozes da vrsis tako sto ces u fajl upisati sadrzaj Document.toString() metode (ako se ne varam)