作者montreal (╮(╯3╰)╭)
看板java
标题Re: [问题] XML Document转String
时间Sun Dec 17 17:02:53 2006
※ 引述《calais007 (浅水中)》之铭言:
: 它文件上面不就有有写
: 要用API之前要先看使用说明阿
: 在Document class的文件说明上toString()这样写
: toString
: public java.lang.String toString()This returns a String representation of the
: Document, suitable for debugging. If the XML representation of the Document
: is desired, XMLOutputter.outputString(Document) should be used.
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: 例如
: XMLOutputter outtper = new XMLOutputter();
: String xml = outter.outputString(document);
: 官方文件上有一章写的
: Reading XML Documents with JDOM
: 看完之後你应该就会知道怎麽做
补完:
/* 把 xmlString 再变回 org.jdom.Document */
SAXBuilder saxBuilder = new SAXBuilder(false);
Reader stringReader = new StringReader(xmlString);
org.jdom.Document doc = saxBuilder.build(stringReader);
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.216.174.175