XMLTextReader¶ÔXMLÎļþµÄ¶ÁÈ¡
using System;
using System.Xml;
namespace ReadXMLfromFile
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
XmlTextReader reader = new XmlTextReader ("books.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + reader.Name);
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine (reader.Value);
break;
case XmlNodeType.EndElement: //Display the end of the element.
Console.Write("</" + reader.Name);
Console.WriteLine(">");
break;
}
}
Console.ReadLine();
}
}
}
Ïà¹ØÎĵµ£º
´´½¨¿ÉÐòÁл¯µÄÀ࣬»òÕß´´½¨ÓÃÓÚ´¦Àí XML ÐòÁл¯ÀàµÄÀà¡£ Èç¹ûÄúÓµÓÐÃèÊöÒª¼ÓÔØ»ò±£´æµÄ XML Îļþ¸ñʽµÄ XML ¼Ü¹¹¶¨Òå (XSD)£¬ÇëʹÓà Xsd.exe ¹¤¾ß×Ô¶¯´´½¨ÕâЩÀà¡£ »¹¿ÉÒÔÊÖ¶¯´´½¨ÕâЩÀà¡£ ÈôҪʹÓà Xsd.exe ¹¤¾ß´´½¨¿ÉÐòÁл¯µÄÀ࣬Çë°´ÕÕÏÂÁв½Öè²Ù×÷£º
½«ÒÔÏÂÃèÊö¶©µ¥µÄ XSD ¼Ü¹¹±£´æÎª Po.xsd Îļþ£º
<xsd:sche ......
XMLÎļþµÄ½âÎö££libxml¿âº¯Êý½âÊÍ[ת]
libxml£¨Ò»£©
ÕªÒª
LibxmlÊÇÒ»¸öÓÐÃâ·ÑÐí¿ÉµÄÓÃÓÚ´¦ÀíXML¡¢¿ÉÒÔÇáËÉ¿çÔ½¶à¸öƽ ......
Create:
int nFQ;
XmlDocument doc = new XmlDocument();
XmlAttribute
newAtt;
//¶¨ÒåXMLÎĵµÍ·Îļþ
XmlDeclaration dec =
doc.CreateXmlDeclaration("1.0",null,null);
doc.AppendChild(dec);
&n ......
Query:
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath(".\\db\\dbGuest.xml"));
//UserÊÇXML¸ù½Úµã,Name×Ö½Úµã
lbEmail.Text =
doc.SelectSingleNode("//User ......
µ½http://sourceforge.net/projects/tinyxml/ÏÂÔØTinyXmlµÄ¹Ù·½Àý×Ó£¬
ÀïÃæÓкü¸¸öÎļþ£¬ÎÒÃǰÑ
tinyxml.h
tinystr.h
tinystr.cpp
tinyxml.cpp
tinyxmlparser.cpp
tinyxmlerror.cpp
Õ⼸¸öÎļþ°üº¬µ½ÎÒÃǵŤ³ÌÄÚ¡£
Òª°üº¬Í·Îļþ #include "tinyxml.h"
ÕâÓþͿÉÒÔ¿ªÊ¼Ê¹ÓÃtinyxml¿ªÊ¼²Ù×÷xmlÎļþÁË£¬¾ßÌåµÄ²Ù×÷· ......