xstream:StreamException如何获取错误行

时间:2018-08-26 11:46:43

标签: xstream

在我的Java项目中,我通过http://x-stream.github.io/解析传入的xml

这是我的代码:

try {
            Account account = (Account) xstream.fromXML(oneM2DocumentAsString);

} catch (StreamException ex) {
            logger.error("Error message " + ex.getMessage(), ex);
                    }

在xml中使用符号“&”时,出现错误:

    [java] [26.08.2018 14:49:05.641] myproject.M2XMLParser.parseOne(M2XMLParser.java:229) ERROR:
 [java]     Error message  : The entity name must immediately follow the '&' in the entity reference.
 [java] com.thoughtworks.xstream.io.StreamException:  : The entity name must immediately follow the '&' in the entity reference.
 [java]     at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:105)
 [java]     at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:77)
 [java]     at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1040)
 [java]     at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1031)

但是我需要知道:

  1. 错误行号
  2. 以文字形式显示内容符号

0 个答案:

没有答案