XML½âÎöÆ÷£¬×Ô¼º¼ÓÁ˵ã×¢ÊÍ¡£Áôµ×
#include <iostream>
#include "1.h"
int main(int argc, char *argv[])
{
try
{
SXmlDOM dom;
//dom.parse("<?xml?><Êéµê><Êé±¾ ÊéÃû="VC++" ¼Û¸ñ="50" ÕÛ¿Û="1"/><Êé±¾ ÊéÃû="VB" ¼Û¸ñ="50" ÕÛ¿Û="0.8"/><Êé±¾ ÊéÃû="C#" ¼Û¸ñ="50" ÕÛ¿Û="0.7">ÓÐÔ´³ÌÐò¹âÅÌ</Êé±¾><¹ÒÀú><Äê·Ý>2006</Äê·Ý><¼Û¸ñ>50</¼Û¸ñ></¹ÒÀú></Êéµê>")
dom.parseFile("test.xml");
//²éѯ
SXmlElement& root = dom.root();
cout << "ÓÐ" << root.count("Êé±¾") << "±¾Êé!"<< endl;
cout << "VBµÄ¼Û¸ñ:" << (int)root.item("Êé±¾", 1)["¼Û¸ñ"] * (float)root.item("Êé±¾", 1)["ÕÛ¿Û"] << endl;
cout << root.at(0).xml();
SXmlElement& gl = root.item("¹ÒÀú");
cout << gl.item("Äê·Ý").text() << endl;
//±éÀú
SXmlNodeList::iterator iter;
for(iter = root.begin(); iter!=root.end(); iter++)
cout << (*iter)->xml();
//¸³Öµ
root.item("Êé±¾", 1)["¼Û¸ñ"] = 60;
root.item("Êé±¾", 1)["ÕÛ¿Û"] = 0.5;
cout << "VBµÄ¼Û¸ñ:" << (int)root.item("Êé±¾", 1)["¼Û¸ñ"] * (float)root.item("Êé±¾", 1)["ÕÛ¿Û"] << e
Ïà¹ØÎĵµ£º
XML¿ª·¢ÈëÃÅ»ù´¡£ºXMLÓï·¨¹æÔò(2) - ÍøÒ³Éè¼ÆרÀ¸ - ±à³ÌÈëÃÅÍø
http://www.bianceng.cn/web/XML/200911/11986_2.htm
×Ö·û ʵÌåÒýÓÃ
> &n ......
private void CreateNewXmlNode()
{
String strFileName = string.Empty;
strFileName = this.strCurrentPath + "System.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(strFileName);
......
±¾ÎÄ×ܽáÁËÔÚPythonÖÐÖ÷ÒªµÄ¼¸ÖÖ´¦ÀíXMLµÄ·½·¨£º
Element Tree
SAX
Dom
ʹÓõÚÈý·½Àà¿âÈçAmara 2.x£¬ libxml2dom µÈ
Element Tree
Element TreeÊÇPython 2.5ÒýÈëµÄʹÓüòµ¥£¬¿ì½ÝµÄ´¦Àí·½·¨£¬ Ò²ÊÇPython±ê×¼Àà¿âÍƼöµÄ´¦ÀíXMLµÄ·½·¨¡£
ËüʹÓÃÊ÷ÐνڵãµÄÐÎʽÀ´¶ÁдXML¡£Element TreeÊÇÇáÁ¿¼¶µÄDOM£¬ ËùÒÔÊ ......
1¡¢µ¼³öµ½XMl select * from Brand for xml auto ,root('Brands')
<Brands>
<Brand BrandID="E584596D-4D66-4F2F-B6F7-71C3BEB4CA21" Name="inganico" />
<Brand BrandID="19B04451-DDC4-4CDF-BE30-CB4E703B27DA" Name="°²¸¶´ï" />
<Brand BrandID="3C6C8E12-7C4A-4F1 ......