Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法使用xstream、stax2、woodstox获取cdata结果_Java_Xml_Xstream_Stax_Woodstox - Fatal编程技术网

Java 无法使用xstream、stax2、woodstox获取cdata结果

Java 无法使用xstream、stax2、woodstox获取cdata结果,java,xml,xstream,stax,woodstox,Java,Xml,Xstream,Stax,Woodstox,示例xml <root> <first> <second><![CDATA[hello, world]]></second> </first> <root> 这是我的示例测试代码 我无法在路径“root/first/second”中获取cdata字符串结果 我认为XMLInputFactory.newInstance()返回类会影响结果 当我加上 factory.setProperty(XMLI

示例xml

<root>
  <first>
    <second><![CDATA[hello, world]]></second>
  </first>
<root>
这是我的示例测试代码

我无法在路径“root/first/second”中获取cdata字符串结果

我认为XMLInputFactory.newInstance()返回类会影响结果

当我加上

factory.setProperty(XMLInputFactory.IS_COALESCING, true);
获取XMLInputFactory.newInstance()之后的代码

它起作用了。 但这似乎不是答案

版本不兼容吗


还有其他可能的方法吗?

你对设置合并有什么问题?如果您只想为所有角色设置一个事件,那么这似乎是正确的做法?当我设置代码xstream时,没有stax2和woodstox,它在没有任何设置的情况下工作正常。我怀疑xstream与stax2或woodstox的兼容性,但我不知道确切的原因。您对设置的问题是什么?如果您只想为所有角色设置一个事件,那么这似乎是正确的做法?当我设置代码xstream时,没有stax2和woodstox,它在没有任何设置的情况下工作正常。我怀疑xstream是否与stax2或woodstox兼容,但我不知道确切原因。
factory.setProperty(XMLInputFactory.IS_COALESCING, true);