| Author |
How can I convert the xml to a string?
|
Leo Tien
Ranch Hand
Joined: Sep 10, 2002
Posts: 156
|
|
Thanks.
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
This is a FAQ. You'll find several answers if you do a search on this forum for "xml string"...
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Leo Tien
Ranch Hand
Joined: Sep 10, 2002
Posts: 156
|
|
Hi, Lasse: I'v seen the topics from the search results, but none is I want. I want use such as Xalan and XSL to convert a XML file to a String. e.g., a XML file have a tag named A and it's text value is a and have a tag named B and it's text value is b. Now, I want to convert it to "ab" String, how should I do? Thanks.
|
 |
cyril vidal
Ranch Hand
Joined: Jul 02, 2003
Posts: 247
|
|
Sorry for the two precedent messages... With XSLT, it is not difficult to get the values of all child elements: As another solution, you may want to use SAX and just use the characters() method, like this: A complete program to do this may be the following (just compile it and run it with xerces in your classpath): Hoe this helps, Cyril.
|
SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
Cyril, I deleted the two posts for you. In the future, you can do it from the "edit/delete" view...
|
 |
 |
|
|
subject: How can I convert the xml to a string?
|
|
|