  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Subject: Re: adding attributes from a string | Subject: Re: adding attributes from a string 2007-09-01 - By Per Norrman
Back Hi,
Construct valid xml from the <source> element text. Ssomething like this:
SAXBuilder builder = new SAXBuilder(); String source = "<source>firstname='john' lastname='doe' age='42'</source>"; Document doc = builder.build(new StringReader(source)); String constructed = "<result " + doc.getRootElement().getText() + "/>"; Document result = builder.build(new StringReader(constructed)); new XMLOutputter().output(result, System.out);
/per
Stefan Shoeman skrev: > Hey, > > how is it possible to add attributes from a string (an example follows > below) to an element? > > Because I have some attributes as text between two tags: > <source>firstname="john" lastname="doe" age="42"</source> > > => string: [firstname="john" lastname="doe" age="42"] > > ...which should become: > <result firstname="john" lastname="doe" age="42"></result> > > Sadly the source xml is given as it is and I don't have any chance to > change it for better fitting into jdom. Any hints would be > appreciated. > > Thanks for reading... > > Regards, > > Stefan > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > To control your jdom-interest membership: > http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected) > >
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|
 |