0

dom4j は問題なく実行できます

String text = "<person> <name>James</name> </person>";
Document document = DocumentHelper.parseText(text);

私が必要なのはこれです

String text = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"+
"<person> <name>James</name> </person>";
Document document = DocumentHelper.parseText(text);

しかし、それは例外をスローします。

org.dom4j.DocumentException: Error on line 1 of document  : parsing initialization error: org.gjt.xpp.XmlPullParserException: only whitespace content allowed outside root element at line 1 and column 1 seen 
4

1 に答える 1

1

私は問題を見つけます。以下の前の行は失敗したものです。アフターラインは機能します。

Document output = DocumentHelper.parseText(response.getEntity(String.class));

Document output = DocumentHelper.parseText(response.getEntity(String.class).trim());
于 2012-10-15T18:21:07.970 に答える