You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Martin Olsson <mn...@minimum.se> on 2005/06/15 13:16:56 UTC

Code that edits XML documents

Hi,

I need to implement a program that modifies an XML file, this file will
frequently also be edited by hand in a plain text editor. Of course, it's
important that the program does not remove or undo any of the hand-edited
changes (xml data, comments or whitespace). I have previously used Xerces
for reading XML.

What library can you recommend for editing/writing XML data? Can Xerces or
some addon do this? Is there anything in the JDK that I missed? Is there
another Apache project for this?

I'm looking for something that is simple, open source and java. Ideally I
would like something that works like this:

void updateXmlTagContent(Sometype document,
                         String xpathSayingWhichTagToUpdate,
                         String newTagContent);

Have anyone seen a library or tool that does this or something similar? It
doesnt have to be based on xpath, any solution that gets the XML document
updated will do.


rgrds,
martin







---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Code that edits XML documents

Posted by Paul Libbrecht <pa...@activemath.org>.
All "DOM-like" libraries would do, or ?
dom4j, jdom (two very good libraries for in-memory representation of 
the XML-tree, both support XPath, JDOM exposes children with 
java-collections) and DOM (which is a standard implemented by Xerces).
Presumably other such libraries as well as stax or xpp can do it.

They all have support for lexical-handling but that's sadly, not enough 
to have everything, for example, entities within attribute-values or 
DTD-implied attributes. Generally this means that the re-output is 
considerably less readable, at least that's my experience.

I'd love to be contradicted!

paul


Le 15 juin 05, à 13:16, Martin Olsson a écrit :

> Hi,
>
> I need to implement a program that modifies an XML file, this file will
> frequently also be edited by hand in a plain text editor. Of course, 
> it's
> important that the program does not remove or undo any of the 
> hand-edited
> changes (xml data, comments or whitespace). I have previously used 
> Xerces
> for reading XML.
>
> What library can you recommend for editing/writing XML data? Can 
> Xerces or
> some addon do this? Is there anything in the JDK that I missed? Is 
> there
> another Apache project for this?
>
> I'm looking for something that is simple, open source and java. 
> Ideally I
> would like something that works like this:
>
> void updateXmlTagContent(Sometype document,
>                          String xpathSayingWhichTagToUpdate,
>                          String newTagContent);
>
> Have anyone seen a library or tool that does this or something 
> similar? It
> doesnt have to be based on xpath, any solution that gets the XML 
> document
> updated will do.
>
>
> rgrds,
> martin
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org