XML XQuery
--XQuery »ùÓÚÏÖÓÐµÄ XPath ²éѯÓïÑÔ£¬²¢Ö§³Ö¸üºÃµÄµü´ú¡¢¸üºÃµÄÅÅÐò½á¹ûÒÔ¼°¹¹Ôì±ØÐèµÄ XML µÄ¹¦ÄÜ¡£
--1.ÉùÃ÷Ò»¸ö xml ÀàÐ͵ıäÁ¿£¬È»ºóʹÓà xml Êý¾ÝÀàÐ굀 query() ·½·¨À´²éѯ´Ë±äÁ¿
DECLARE @x xml
SET @x = '<ROOT><a>111</a></ROOT>'
SELECT @x.query('/ROOT/a')
--²éÕÒÊôÐÔaid=20µÄa½Úµã
DECLARE @x xml
SET @x = '<ROOT>
<a aid="10">10</a>
<a aid="20">20</a>
</ROOT>'
SELECT @x.query('/ROOT/a[@aid=20]')
--2.ѯÊÇÕë¶Ô AdventureWorks Êý¾Ý¿âÖÐ ProductModel ±íµÄ xml ÀàÐ굀 Instructions ÁÐÖ¸¶¨µÄ¡£
--²éÕÒÌõ¼þProductModelID=7£¬ÊôÐÔLocationID=10µÄLocation½Úµã
SELECT Instructions.query('declare namespace AWMI="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions";
/AWMI:root/AWMI:Location[@LocationID=10]
') as Result
from Production.ProductModel
WHERE ProductModelID=7
--XQuery °üº¬ÃüÃû¿Õ¼äÉùÃ÷£¨declare namespace AWMI=...£©ºÍ²éѯ±í´ïʽ£¨/AWMI:root/AWMI:Location[@LocationID=10]£©¡£
DECLARE @x xml
SET @x = '<ROOT>
<a aid="10">10</a>
<a aid="20">20</a>
</ROOT>'
SELECT @x.query('/ROOT/a[@aid=20]')
Ïà¹ØÎĵµ£º
µ±ÊäÈë ¡·Ê±×Ô¶¯²¹È« µ±ÊäÈë¡¶/ʱ×Ô¶¯²¹È«
“£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
" File: closetag.vim
" Summary: Functions and mappings to close open HTML/XML tags
" Uses: <C-_> -- close matching open tag
" Author: Steven Mueller <di ......
Éú³É¶Ë´¦Àí
½«ÒªÐ´ÈëµÄÖµµÄǰºóдÉÏÈç:"<![CDATA[" + string+ "]]>";
XmlNode xnformchild = doc.CreateNode(XmlNodeType.Element, dc.ColumnName.ToUpper(), "");
try
{
xnformchild.InnerXml = drform[dc.ColumnName].ToString( ......
·Ü¶·Á˽«½üÒ»¸öÔÂÒÆÖ²gloox¿âµ½brewƽ̨£¬ÔÚxml½âÎöµÄ×¼±¸Õâ±ß»¨Á˲»ÉÙʱ¼ä¡£ÆÚ¼äÒ²ÖØÐ·â×°Á˱ê×¼¿âµÄstring¡¢map¡¢listÀ࣬ÏÖÔÚ»ØÍ·ÏëÏëÊÕ»ñ»¹ÊÇÂù´óµÄ£¬µ«ÊÇÃ²ËÆÊÇÎÞÓõġ£
gloox´Ó0.9°æ±¾¿ªÊ¼¾Íno dependency on iksemel anymore£¬¶øiksemel×î³õÊÇרÃÅΪjabberдµÄxml½âÎöÆ÷£¬Õâô¿´À´£¬¶ÔÕâ¸öʱ¼ä·Ç³£½ôÆÈµÄÏîÄ¿À´Ëµ£ ......
¹¤¾ß:myeclipse 6.5
jsonÖÐÎĹٷ½£ºhttp://www.json.org/json-zh.html
н¨ÏîÄ¿webs£¬ÔÚWebRootÏÂн¨Ä¿Â¼json
xmlµÄ½âÎö·½Ê½:
------------------------------------------------------------------
1.н¨NewFile.xml
<?xml version="1.0" encoding="UTF-8"?>
<userinfo>
  ......
´´½¨XMLÎļþ£º
public boolean createXML(){
try{
Document doc = DocumentHelper.createDocument();
Element root = doc.addElement("root");
Element personNode = root.addElement("person");
Element sonNode = personNode ......