²éѯXMLÎĵµ
±êÇ©£ºÊý¾Ý·ÃÎÊ ADO.NET
²éѯXMLÎĵµ LINQ to XMLÀàÌṩÊôÐԺͷ½·¨£¬·µ»Ø¿É²éѯµÄÀàµÄ¶ÔÏ󼯺ϡ£
½«XML¶ÔÏó×÷ΪLINQ²éѯ¶ÔÏó£º
.......
XDocument customers = XDocument.Load(xmlFileName);
var queryResult = from c in customers.Elements() select c.Name;
ʹÓòéѯ³ÉÔ±
1£©Element()£º·µ»ØÎĵµ »ò Ƭ¶ÎÖеĵÚÒ»¸öÔªËØ¡£ÎĵµµÄ»°¾Í·µ»Ø¸ùÔªËØ£» 2£©Descendants()£º·µ»ØÎĵµ »ò Ƭ¶ÎÖеÄËùÓÐ×ÓÔªËØ£¨ËùÓм¶±ð£©£» Àý£ºqueryResults = from c in customers.Descendants() select c.Name; foreach (var item in queryResults.Distinct()) //ɸѡ³ö²»Í¬µÄÔªËØ
Descendants(string)ÖØÔØ£º queryResults = from c in customers.Desendants("customer") select c; //²éѯָ¶¨Ãû³ÆµÄ×ÓÔªËØ£¬·µ»ØËùÓÐcustomerÔªËØ¡£
3£©Ancestors()£º·µ»Ø±ÈÔ´ÔªËؼ¶±ð¸ßµÄÒ»×éÔªËØ£»
4£©Attribute()£º·µ»Øµ±Ç°Ñ¡ÖÐÔªËصÄËùÓÐÊôÐÔ£»
Àý£ºqueryResults = from c in customers.Descendants("customer").Attributes() select c; //·µ»ØcustomersÖÐËùÓÐcustomerÔªËصÄÊôÐÔÖµ
Ïà¹ØÎĵµ£º
var
xmlDoc
=
null
;
function
parseXML
(
xmlUrl
)
{
¡¡¡¡try
{
¡¡¡¡¡¡¡¡//IE
¡¡¡¡¡¡¡¡xmlDoc
=
new
ActiveXObject
(
"Microsoft.XMLDOM"
);
¡¡¡¡¡¡¡¡xmlDoc
.
async
=
false
;
¡¡¡¡¡¡¡¡xmlDoc
......
XMLÎļþʵÀý£º
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource auth="Container" maxActive="20" name="sss" password="123"
type="javax.sql.DataSource" />
<Resource auth="Container" ......
ÏÖÔÚÎÒÃÇÔÝÇÒʹÓÓ¼Çʱ¾”À´´´½¨ÎÒÃǵÄXMLÎļþ°É¡£ÏÈ¿´Ò»¸öXMLÎļþ£º
¡¡¡¡Àý1
¡¡¡¡¡´?xml version="1.0" encoding="gb2312" ?¡µ
¡¡¡¡¡´²Î¿¼×ÊÁÏ¡µ
¡¡¡¡ ¡´Êé¼®¡µ
¡¡¡¡ ¡´Ãû³Æ¡µXMLÈëÞ«½â¡´/Ãû³Æ¡µ
¡¡¡¡ ¡´×÷Õß¡µÕÅÈý¡´/×÷Õß¡ ......
ÔÚweb.config×ö參數設¶¨時Óöµ½ÌØÊâ×ÖÔª value="http://www.yahoo.com.tw/default.aspx?sid=111111111&uid=test"
&uid這µØ·½會³ö錯...換³É&uid ¾ÍOKÁË~~
幾個
對ÕÕÈçÏÂ:
< Сì¶
<
> ´óì¶
>
&
& ......
package com.jcauto.action;
import java.util.ArrayList;
import java.util.List;
public class ContentRsp {
private String resultCode;
List<ContentInfo> contentList = new ArrayList<ContentInfo>();
public void addContent(ContentInfo contentInfo) {
contentList.add(contentI ......