XML ¶Á
StringBuilder output = new
StringBuilder();
String xmlString =
@"<bookstore>
<book genre='novel' ISBN='10-861003-324'>
<title>The Handmaid's Tale</title>
<price>19.95</price>
</book>
<book genre='novel' ISBN='1-861001-57-5'>
<title>Pride And Prejudice</title>
<price>24.95</price>
</book>
</bookstore>";
// Load the file and ignore all white space.
XmlReaderSettings settings = new
XmlReaderSettings();
settings.IgnoreWhitespace = true
;
using
(XmlReader reader = XmlReader.Create(new
StringReader(xmlString), settings))
{
// Move the reader to the second book node.
reader.MoveToContent();
reader.ReadToDescendant("book"
);
reader.Skip();
//Skip the first book.
// Parse the file starting with the second book node.
do
{
switch
(reader.NodeType)
{
case
XmlNodeType.Element:
output.AppendLine("<"
+ reader.Name);
while
(reader.MoveToNextAttribute())
{
output.AppendLine(" "
+ reader.Name + "="
+ reader.Value);
}
output.AppendLine(">"
);
break
;
case
XmlNodeType.Text:
output.AppendLine(reader.Value);
break
;
case
XmlNodeType.EndElement:
output.AppendLine("</"
+ reader.Name + ">"
);
break
;
}
}
while
(reader.Read());
}
OutputTextBlock.Text = output.ToString();
XMLÊÇÄ¿Ç°×î³£ÓõÄͨÓÃÊý¾Ý´«ÊäÓë´¦Àí½Ó¿ÚÀàÐÍ¡£±¾ÎĽéÉÜÈçºÎÓÃC#.NET¶ÁдXMLÎĵµ×ÊÁÏ¡£
<?xml version="1.0" encoding="utf-8"?>
Ïà¹ØÎĵµ£º
XML Schema attributeGroup ÔªËØ
¶¨ÒåºÍÓ÷¨
attributeGroup ÔªËØÓÃÓÚ¶ÔÊôÐÔÉùÃ÷½øÐÐ×éºÏ£¬ÕâÑùÕâЩÉùÃ÷¾ÍÄܹ»ÒÔ×éºÏµÄÐÎʽºÏ²¢µ½¸´ÔÓÀàÐÍÖС£
ÔªËØÐÅÏ¢
³öÏÖ´ÎÊý
ÎÞÏÞÖÆ
¸¸ÔªËØ
attributeGroup¡¢complexType¡¢schema¡¢restriction (simpleContent)¡¢extension (simpleContent)¡¢rest ......
XML½âÎöÆ÷µÄ×÷ÓãºÎªÓ¦ÓóÌÐò´ÓXMLÎļþÖнâÎö³öËùÐèÒªµÄÊý¾Ý¡£
ÏÂÃæͨ¹ýÒ»¸öÀý×Ó£¬À´Á˽⣬ÈçºÎÓÃXML½âÎöÆ÷£¬À´½âÎöÒ»¸öXMLÎļþÖеÄÊý¾Ý¡£
1¡¢Types.xml£¨ÏÔʾ¼ªËûµÄÀà±ð£©
<?xml version="1.0" encoding="UTF-8"?>
<types>
<name>µç¼ªËû
<music>ÍæÒ¡¹ö</music>
</name>
......
·¶ÀýÈçÏ£º
var xml:XML=
<body>
text1
<bar>barText1</bar>
& ......
Delphi²Ù×÷XMLÊǺܷ½±ãµÄ£¬Ö÷ÒªÓÐÁ½ÖÖ·½·¨£»
1.ÓÃTClientDataSet²Ù×÷XML£»TClientDataSetÊǸöºÃ¶«Î÷£¬ÓÃËü²Ù×÷XMLÊǺܼòµ¥µÄÊ£¬²»¹ýȱµãÊÇÖ»ÄܲÙ×÷¹Ì¶¨¸ñʽµÄ XML£¬ËüÊʺϲÙ×÷±í½á¹¹µÄÊý¾Ý£¬Èç¹ûÄãÐèÒª°ÑÊý¾Ý±íµ¼³ö³ÉXMLÄÇÓÃTClientDataSetÊǸöºÃÖ÷Ò⣬±ÈÈçÏÂÃæÊÇÒ»¸öÊý¾Ý¼¯µ¼³ö³ÉXMLµÄ· ......