Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÁË
¡¡¡


Ïà¹ØÎĵµ£º

½»»»Êý¾Ýѧϰһ£º½«xmlÎı¾¶ÁÈ¡µ½DataSet²¢ÏÔʾ

//xmlÎĵµÄÚÈÝ
<?xml version = "1.0" encoding="gb2312" standalone="yes"?>
<VFPData>
 <company>
  <companyno>100</companyno>
  <companyname>ÉϺ£</companyname>
  <ceoname>³ÂËÄ</ceoname>
  <ceoma ......

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

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


°üλÖãºandroid.widget.TextView
XML Attributes
 
Attribute Name                 Related Method                   &n ......

Jdom½¨Á¢XMLÎļþ


   JDOM ÊÇÒ»¸ö¿ªÔ´µÄ´¿java API,ÓÃÓÚ¿ìËÙ¿ª·¢ XML Ó¦ÓóÌÐò,JDOM½«XMLÎĵµ±íʾΪÊ÷£¬°üÀ¨ÔªËØ¡¢ÊôÐÔ¡¢ËµÃ÷¡¢´¦ÀíÖ¸Áî¡¢Îı¾½Úµã¡¢CDATA¶Î£¬µÈµÈ¡£JDOM¿ÉÒÔËæʱ·ÃÎÊÊ÷ÖеÄÈÎÒⲿ·Ö¡£Ê÷ÖÐËùÓв»Í¬½Úµã¾ùΪ¾ßÌåµÄÀà¡£ÔÚhttp://jdom.org¿ÉÒÔÏÂÔØJDOMµÄ×îа汾(ÎÒÕâÀïÊÇ1.0)¡£ÏÂÔغó½âѹ£¬JDOMµÄjarÎļþ¾ÍÊÇbuildÄ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ