XML×Ö·û´®ºÍXML DOCUMENTµÄÏ໥ת»»
±¾ÎÄÉæ¼°µ½XML×Ö·û´®ºÍXml DocumentµÄת»»ÎÊÌ⣬¾Í¸÷ÖÖXML½âÎöÆ÷·Ö±ðÁоÙÈçÏ£¬ÒÔ·½±ã½ñºó²éÔÄ¡£
¡¡¡¡Ò»¡¢Ê¹ÓÃ×îÔʼµÄjavax.xml.parsers£¬±ê×¼µÄjdk api
¡¡¡¡// ×Ö·û´®×ªXML
¡¡¡¡String xmlStr = \"......\";
¡¡¡¡StringReader sr = new StringReader(xmlStr);
¡¡¡¡InputSource is = new InputSource(sr);
¡¡¡¡DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
¡¡¡¡DocumentBuilder builder=factory.newDocumentBuilder();
¡¡¡¡Document doc = builder.parse(is);
¡¡¡¡//XMLת×Ö·û´®
¡¡¡¡TransformerFactory tf = TransformerFactory.newInstance();
¡¡¡¡Transformer t = tf.newTransformer();
¡¡¡¡t.setOutputProperty(\"encoding\",\"GB23121\");//½â¾öÖÐÎÄÎÊÌ⣬ÊÔ¹ýÓÃGBK²»ÐÐ
¡¡¡¡ByteArrayOutputStream bos = new ByteArrayOutputStream();
¡¡¡¡t.transform(new DOMSource(doc), new StreamResult(bos));
¡¡¡¡String xmlStr = bos.toString();
¡¡¡¡ÕâÀïµÄXML DOCUMENTΪorg.w3c.dom.Document
¡¡¡¡¶þ¡¢Ê¹ÓÃdom4jºó³ÌÐò±äµÃ¸ü¼òµ¥
¡¡¡¡// ×Ö·û´®×ªXML
¡¡¡¡String xmlStr = \"......\";
¡¡¡¡Document document = DocumentHelper.parseText(xmlStr);
¡¡¡¡// XMLת×Ö·û´®
¡¡¡¡Document document = ...;
¡¡¡¡String text = document.asXML();
¡¡¡¡ÕâÀïµÄXML DOCUMENTΪorg.dom4j.Document
¡¡¡¡Èý¡¢Ê¹ÓÃJDOM
¡¡¡¡JDOMµÄ´¦Àí·½Ê½ºÍµÚÒ»ÖÖ·½·¨´¦Àí·Ç³£ÀàËÆ
¡¡¡¡//×Ö·û´®×ªXML
¡¡¡¡String xmlStr = \".....\";
¡¡¡¡StringReader sr = new StringReader(xmlStr);
¡¡¡¡InputSource is = new InputSource(sr);
¡¡¡¡Document doc = (new SAXBuilder()).build(is);
¡¡¡¡//XMLת×Ö·û´®
¡¡¡¡Format format = Format.getPrettyFormat();
¡¡¡¡format.setEncoding(\"gb2312\");//ÉèÖÃxmlÎļþµÄ×Ö·ûΪgb2312£¬½â¾öÖÐÎÄÎÊÌâ
¡¡¡¡XMLOutputter xmlout = new XMLOutputter(format);
¡¡¡¡ByteArrayOutputStream bo = new ByteArrayOutputStream();
¡¡¡¡xmlout.output(doc,bo);
¡¡¡¡String xmlStr = bo.toString();
¡¡¡¡ÕâÀïµÄXML DOCUMENTΪorg.jdom.Document
¡¡¡¡ËÄ¡¢JAVASCRIPTÖеĴ¦Àí
¡¡¡¡//×Ö·û´®×ªXML
¡¡¡¡var xmlStr = \".....\";
¡¡¡¡var xmlDoc = new ActiveXObject(\"Microsoft.XMLDOM\");
¡¡¡¡xmlDoc.async=false;
¡¡¡¡xmlDoc.loadXML(xmlStr);
¡¡¡¡//¿ÉÒÔ´¦ÀíÕâ¸öxmlDocÁË
¡¡¡
Ïà¹ØÎĵµ£º
×ÖºÅ: С ÖÐ ´ó | ´òÓ¡ ·¢²¼: 2009-1-08 16:33 ×÷Õß: webmaster À´Ô´: ±¾Õ¾Ô´´ ²é¿´: 40´Î
Êé½ÓÉϻأ¬ÕâÆª½éÉÜÄǸöMContentHandlerµÄʵÏÖ£¬ÕâÊÇSAX½âÎö·½·¨µÄºËÐÄËùÔÚ¡£
ÏÈ¿´¿´ÎÒÒª½âÎöµÄXMLÎļþÈçÏÂËùʾ£¬ÆäʵºÜ¼òµ¥£¬ÒòΪËü³ýÁËEle ......
Paul.Todd | 09 April, 2007 15:24
I have noticed a couple of people seem to be having problems with using the XML parser in Symbian and there are no examples outside of the devkit. The parser I will be talking about is the xml one, not the one SOAP engine as the SOAP one is Nokia specific.
The ke ......
antonypr | 14 April, 2007 00:05
A couple of weeks ago, I had a plan to write an article and example code of using XML parser in Symbian OS. It seems that another Forum Nokia Champion, Paul Todd had the same idea. He posted a nice article about XML parser in Symbian OS 9.x to Forum Nokia Blogs. It's ......
1. login_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_logo"
>
......