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ÎļþʱûÓÐÎÊÌ⣬ÓÐЩȴÓÐÎÊÌâ¡£ÎҺܿàÄÕ£¡ÊDz»ÊÇÎÒµÄ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 ......
htmlÒ³Ãæ¾²Ì¬´´½¨xmlÎļþ£¬²¢±£´æ£¬ÒÔºó¿ÉÒÔ¶ÁÈ¡¡£
²»ÖªÄÄλ´óÏÀ×ö¹ý¡£¡£¡£
лл
javascriptÓ¦¸Ã²»ÄÜ´´½¨Îļþ°É
jsÓÐȨÏÞ´´½¨Ã´£¬´ó¶àÊýÇé¿öϱ»½ûÖ¹°É
ȨÏÞ¡£¡£
ÀúÊ·ÒÅÁôÎÊÌ⣬¿´À´½â¾ö²»ÁËÁË¡£¡£¡£¡£¡ ......
ÈçÌ⣬ÎÒÏëÓÃdom4jÀ´¶ÁÈ¡xmlµÄÎļþ
public Document read(String fileName) throws MalformedURLException, DocumentException {
SAXReader reader = new SAXReader();
Document document = read ......