xml解析问题!急
我是利用axiom对xml进行解析!
但却出现下面的错误!
Exception in thread "main" org.apache.axiom.om.OMException: [com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) (missing name?)
at [row,col {unknown-source}]: [136,53]
程序在执行有些xml文件时没有问题,有些却有问题。我很苦恼!是不是我的xml文件有问题啊?
Java code:
public class AxiomDemo {
public static void writeToFile(OutputStream os, byte[] b) {//写内容写到文件里面
try {
os.write(b, 0, b.length);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void writeToFile(OutputStream os, OMElement om) {
try {
String str = om.toStringWithConsume();
byte[] b = str.getBytes();
//os.write(b, 0, b.length);
writeToFile(os, b);
} catch (XMLStreamException e) {
// TODO: handle exception
}
}
public static OMElement readQuestionXml(InputStream is) {
OMElement om = null;
try {
XMLStreamReader parser = XMLInputFactory.newInstance()
.createXMLStreamReader(is);
StAXOMBuilder builder = new StAXOMBuilder(parser);
相关问答:
DataSet导出xml 批处理(循环)得怎么处理
XML文件
<A>
<B>
<C>
</C>
&nb ......
<?xml version="1.0"?>
<root>
<status>433</status>
<msg>这个是汉字</msg>
<serialno>123</serialno>
</root>
如何用ASP读取 status值 ......
我有一个类似的xml的 string,想通过遍历怎么个xml 输出我想要的element的值
xml 为:
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>DISCOVER_XML_ME ......
package com.javabean.xml;
import java.net.MalformedURLException;
import java.net.URL;
import org.dom4j.io.SAXReader;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Docum ......