Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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ÁË
¡¡¡


Ïà¹ØÎĵµ£º

How to parse XML file using CParser class


Reviewer Approved    
The following example shows how to parse XML file using Symbian OS C++ class, CParser. CParser is basically a SAX (Simple API for XML)-based XML parser.
It uses an active object to read the XML file chunk by chunk (see CXmlHandler::StartParsingWithAoL( ......

Example Code of Using XML Parser in Symbian OS

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 ......

AndroidÅÄÕÕÉÏ´«³ÌÐòµÄxmlÅäÖÃÎļþ

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"
>
......

¶ÁÈ¡ÅäÖÃÎļþ[·½Ê½Èý]Ö®xml½âÎöÅäÖÃÎļþ·¨

±¾ÎÄת×Ô£ºhttp://blog.csdn.net/wqf363/archive/2006/11/18/1394600.aspx
ʹÓüò½é
Êý¾ÝÀàÐÍ£º
xmlChar  Ìæ´úchar,ʹÓÃUTF-8±àÂëµÄÒ»×Ö½Ú×Ö·û´®¡£Èç¹ûÄãµÄÊý¾ÝʹÓÃÆäËü±àÂ룬Ëü±ØÐ뱻ת»»µ½UTF-8²ÅÄÜʹÓÃlibxmlµÄº¯Êý¡£
XmlDoc °üº¬ÓɽâÎöÎĵµ½¨Á¢µÄÊ÷½á¹¹£¬xmlDocPtrÊÇÖ¸ÏòÕâ¸ö½á¹¹µÄÖ¸Õë¡£
xmlNodePtr and xm ......

TextView ÔÚxmlÎļþÖеĽâÊÍ


°üλÖãºandroid.widget.TextView
XML Attributes
 
Attribute Name                 Related Method                   &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ