²éѯ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
......
public int createXMLFile(String filename) {
int returnValue = 0;
Document document = DocumentHelper.createDocument(); //Éú³ÉDocument£¬ÓÃÓÚ¹ÜÀíXMLÎĵµ
Element booksElement = document.addElement("books"); //Ìí¼Ó ......
ʹÓÃjavascript´´½¨Microsoft XML DOM,¾Í¿ÉÒÔÍê³ÉÕâÒ»¹¤×÷.
// ×°ÈëÊý¾Ý.
var source = new ActiveXObject("Microsoft.XMLDOM");
source.async = false
source.load("history.xml");
// ×°ÈëÑùʽ±í.
var stylesheet = new ActiveXObject("Microsoft.XMLDOM");
stylesheet.async = false
stylesheet.load( ......
from:
http://zhidao.baidu.com/question/67891842.html?si=1
ÏÂÃæµÄÒ»ÐоÍÊÇÔÚµÚ¶þ±¾ÊéµÄ¶¨Òå֮ǰµÄ£º
<?page render multiple authors ?>
ËäÈ»Ëü¿´ÉÏÈ¥ºÜÏñXMLÐòÑÔ£¬µ«Êµ¼ÊÉÏÊÇÒ»ÖÖ³ÆΪ´¦ÀíÖ¸Áprocessing instruction£©µÄ²»Í¬ÀàÐ͵ÄÓï·¨¡£´¦ÀíÖ¸ÁÒÔϼò³ÆPI£©µÄÄ¿µÄÊÇΪÁ˸ø´¦ÀíÒ³ÃæµÄ³ÌÐò£¨ÀýÈçXML½âÎöÆ ......
×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.
Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.
Attribute, Ö¸ÔÚ<Employee >ÖеĴ ......