XML´´½¨¡¢¶Á¡¢Ð´²Ù×÷
Create:
int nFQ;
XmlDocument doc = new XmlDocument();
XmlAttribute
newAtt;
//¶¨ÒåXMLÎĵµÍ·Îļþ
XmlDeclaration dec =
doc.CreateXmlDeclaration("1.0",null,null);
doc.AppendChild(dec);
XmlElement
docRoot = doc.CreateElement("Orders");
doc.AppendChild(docRoot);
for(int i=0;i<12;i++)
{
XmlNode Order =
doc.CreateElement("Order");
newAtt =
doc.CreateAttribute("Quantity");
nFQ = 10*i +i;
newAtt.Value
= nFQ.ToString();
Order.Attributes.Append(newAtt);
docRoot.AppendChild(Order);
}
//
±£´æXMLÎĵµ
string strPath = Server.MapPath("OutDocument.XML");
doc.Save(strPath);
Read:
Ò»£º
// ´´½¨XmlDocumentÀàµÄʵÀý
XmlDocument doc = new XmlDocument();
ArrayList
NodeValues = new ArrayList();
// °Ñpeople.xmlÎļþ¶ÁÈëÄڴ棬ÐγÉÒ»¸öDOM½á¹¹
doc.Load(
Server.MapPath("people.xml") );
XmlNode root =
doc.DocumentElement;
foreach( XmlNode personElement in
root.ChildNodes )
//°É½Úµã¼ÓÈëÊý×é
NodeValues.Add(personElement.FirstChild.Value);
//ÔÚListBoxÖÐÏÔʾ
XMLNodeListBox.DataSource = NodeValues;
XMLNodeListBox.DataBind();
¶þ£º
//¶ÁÈ¡XMLµ½DataSet
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(".\\db\\dbGuest.xml"));
GridView1.Dat
Ïà¹ØÎĵµ£º
¶ÔÓÚ´øÓбí¿Õ¼äxmlnsµÄxmlÎļþµÄ½âÎö£¬ÓÃÕý³£½âÎöÎļþµÄ·½·¨×ÜÊÇʧЧ£¬²»Æð×÷Óã¬ÎÞ·¨»ñµÃÔªËØ¡£
ÏÂÃæ¸ø³öÁ½ÖÖ·½·¨½âÎö´ËÀàÎļþ£º
1.°´Õý³£½âÎöxmlÎļþµÄ·½·¨£¬ÐèҪעÒ⼸µã£º
»ñÈ¡ÔªËØElement£¬²»¿ÉʹÓú¯Êý£ºdocument.selectNodes("//region");
Ö»¿ÉÒÔÏÈÈ¡µ½¸ùÔªËØ£¬Ò»¼¶Ò»¼¶ÍùÏÂÈ¡£¬eg£º
Element root = document.g ......
Ò» DOM ÒÔÏ´úÂëÓÃDOMÊÇÉú³ÉÒ»¸öXMLÎĵµ
package xml;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
imp ......
¿ª·¢¹ýAndroidÓ¦ÓõÄͬѧÃǶ¼ÖªµÀ£¬Android¹¤³Ì-res-layout×ÊÔ´Îļþ¼ÐÏ´æ·Å×Å¿ØÖÆview²¼¾ÖµÄxmlÎļþ£¬ÎÒÃÇ¿ÉÒÔͬ¹ýgetViewById(int i)·½·¨£¬´ÓXMLÖй¹Ôìview¼°Æä×ÓÀ࣬ÔÚÕâ¸ö¹ý³Ìµ±ÖУ¬XMLÎļþÖеÄÒ»ÇÐlayoutÊôÐÔÒ²½«±»¸³ÓèÕâ¸öview¡£µ±È»£¬ÎÒÃÇÒ²Äܹ»Í¨¹ý´úÂëÀ´ÎªÄ³Ò»¸öviewÀ´ÉèÖÃlayout£¬ÄÇÊǺ󻰡£Í¨¹ý¶Ô¼ ......
1.Òª½âÎöµÄXMLÎļþÈçÏ£º
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet href="student.xsl" type="text/xsl"?>
<StudentInfo>
<student>
<name>´ïÄÚ</name>
<sex>ÄÐ</sex>
<lesson>
  ......
package com.flxx.docUrl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jd ......