org.dom4j.DocumentException: Error on line 1 of document : The markup in the document following the

出错记录:

org.dom4j.DocumentException: Error on line 1 of document  : The markup in the document following the root element must be well-formed. Nested exception: The markup in the document following the root element must be well-formed.

at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.dom4j.DocumentHelper.parseText(DocumentHelper.java:278)
at ouc.sei.xmloper.Result2Bean.str2Dom(Result2Bean.java:41)
at ouc.sei.xmloper.Result2Bean.strMap2DomMap(Result2Bean.java:57)
at ouc.sei.xmloper.Result2Bean.getSearchBean(Result2Bean.java:26)
at ouc.sei.result.GetSearchResult.getSearchResult(GetSearchResult.java:39)
at ouc.sei.result.GetSearchResult.test(GetSearchResult.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

解决方案:在xml文件当中一定要有“根“的概念,出错的原因是xml当中没有”根“。在最外面加一个节点即可。

如:<?xml version="1.0" encoding="UTF-8"?>

<a href="test">test</a>

<a href="test">test</a>

<a href="test">test</a>

 这种情况,就会报错,因此要改为:

<?xml version="1.0" encoding="UTF-8" ?>

<root>

<a href="test">test</a>

<a href="test">test</a>

<a href="test">test</a>

</root>

即可正确!


你可能感兴趣的:(org.dom4j.DocumentException: Error on line 1 of document : The markup in the document following the)