Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

VC¶ÁдXMLÎļþ


½ñÌì¶ÔXMLÎļþ½øÐÐÁËһЩ¼òµ¥µÄ¶Áд²Ù×÷£¬ÏÂÃæÀ´¾ßÌåʵÏÖ²½Ö裺
Ê×ÏÈ£º½¨Á¢Ò»¸ö»ùÓÚDialogµÄMFC¹¤³Ì£¬¹¤³ÌÃûΪOperateXML£¬È»ºóÔÚ¶Ô»°¿òÉÏÌí¼ÓÁ½¸ö°´Å¥("Create"ºÍ"GetData"ºÍÒ»¸öListControl
¿Ø¼þ(ÓÃÀ´ÏÔʾÊý¾Ý)£¬Ê×ÏÈÒªµ¼Èë¿âÎļþ
#import "msxml3.dll"
using namespace MSXML2;
Ö÷ÒªÓÃÀ´ÊµÏÖXMLÎļþµÄÏà¹Ø²Ù×÷£¬
Ë«»÷"Create"°´Å¥½øÈë´úÂë±àд£¬´úÂëÈçÏ£º
void COperateXML::OnBtnCreate() 
{
// TODO: Add your control notification handler code here
::CoInitialize(NULL); //³õʼ»¯COM
MSXML2::IXMLDOMDocumentPtr pDoc;
MSXML2::IXMLDOMElementPtr xmlRoot;
HRESULT hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument30));
if(!SUCCEEDED(hr))
{
   MessageBox("Error");
   return;
}
pDoc->raw_createElement((_bstr_t)(char*)"china", &xmlRoot);
pDoc->raw_appendChild(xmlRoot, NULL);
MSXML2::IXMLDOMElementPtr childNode;
pDoc->raw_createElement((_bstr_t)(char*)"city", &childNode);
childNode->Puttext("shanghai");
childNode->setAttribute("population", "7000");
childNode->setAttribute("area", "2000");
xmlRoot->appendChild(childNode);
pDoc->raw_createElement((_bstr_t)(char*)"city", &childNode);
childNode->Puttext("beijing");
childNode->setAttribute("population", "39999");
childNode->setAttribute("area", "3322");
xmlRoot->appendChild(childNode);
pDoc->save("D:\\test.xml");
}
Ë«»÷"GetData"°´Å¥½øÈë´úÂë±àд£¬´úÂëÈçÏ£º
void COperateXML::OnBtnGet() 
{
// TODO: Add your control notification handler code here
m_list.DeleteAllItems();
MSXML2::IXMLDOMDocumentPtr pDoc;
HRESULT hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument30));
if(!SUCCEEDED(hr))
{
   MessageBox("Error!");
   return;
}
pDoc->load("D:\\test.xml");
MSXML2::IXMLDOMElementPtr childNode;
childNode = (MSXML2::IXMLDOMElementPtr)(pDoc->selectSingleNode("//city"));
MSXML2::DOMNodeType nodeType;
childNode->get_nodeType(&nodeType);
MSXML2::IXMLDOMNamedNodeMapPtr pAttrs = NULL;
MSXML2::IXMLDOMNode


Ïà¹ØÎĵµ£º

Integration with the XML Data Type

Integration with the XML Data Type
With the introduction of the XML data type, we wanted to also give FOR XML the ability to generate an instance of XML directly (more precisely, it generates a single row, single column rowset where the cell contains the XML data type instance).
Because of the bac ......

C#¶ÔXML¶Áд

×ªÔØ×Ô£ºhttp://virgos.javaeye.com/blog/611146
Ò»£®Ç°ÑÔ£º
XMLÊÇ΢Èí.NetÕ½ÂÔµÄÒ»¸öÖØÒª×é³É²¿·Ö£¬¶øÇÒËü¿ÉνÊÇXML Web·þÎñµÄ»ùʯ£¬ËùÒÔÕÆÎÕ.Net¿ò¼ÜϵÄXML¼¼Êõ×ÔÈ»ÏԵ÷dz£ÖØÒªÁË¡£±¾ÎĽ«Ö¸µ¼´ó¼ÒÈçºÎÔËÓÃC#ÓïÑÔÍê³É.Net¿ò¼ÜϵÄXMLÎĵµµÄ¶Áд²Ù×÷¡£Ê×ÏÈ£¬ÎÒ»áÏò´ó¼Ò½éÉÜ.Net¿ò¼ÜÖÐÓëXMLÏà¹ØµÄÃüÃû¿Õ¼äºÍÆäÖеÄÖØÒªÀ ......

°ÑÎı¾¿òµÄֵдÈëµ½xmlÎļþÖÐ

 protected void btn_write_Click(object sender, EventArgs e)
    {
        XmlWriterSettings settings=new XmlWriterSettings();
        settings.Indent=true;
        setting ......

dom4j¶Ôxml±È½ÏÍêÕûµÄ²Ù×÷

×î½üдµÄ²å¼þÓõ½ÁËdom4j£¬À´¶Áд£¬ÐÞ¸ÄÎĵµ¡£Óõ½µÄ¹¦Äܶ¼Ð´³öÀ´ÁË
ÏÂÃæ°üº¬ÁËÁ½¸ö³ÌÐò WriteFriendsInfo£¬ºÍ ReadFriendsInfo¡£
1.WriteFriendsInfo °üº¬ÁËн¨xmlºÍÐ޸ģ¬É¾³ýxml½ÚµãµÄ·½·¨
 Ò»Ð©Òªµã£º
    WriteFriendsInfo ÖÐÐ޸Ľڵã²ÉÓõķ½Ê½ÊÇɾ³ý½Úµã£¬È»ºó°ÑеĽڵãд½øÈ¥¡£ÔÚ²»¶Ô¶Á ......

StrutsÖÐÀûÓÃactionÀ´Êä³öxmlÎļþ

      Ó¦Ò»¸öͬʵÄÒªÇó£¬ÒªÀûÓÃstrtusµÄAction½«Ò»¸öÊý¾Ý¿â±íµÄÊý¾ÝÊä³öΪxml¸ñʽµÄÊý¾Ý£¬·½±ãµ¼ÈëʹÓ᣾­Ñо¿Action»¹ÕæÄܰ쵽£¬Êµ¼ÊÉϲ»ÊÇActionµÄ¹¦ÀÍ£¬¶øÊÇJDOMµÄ¹¦ÀÍ£¬²»ËµÄÇô¶àÁË£¬¸ø´ó¼Ò·ÖÏíһϡ£     ÎÒÓÐÒ»¸ö²âÊÔ±í£¬ÓÐÁ½¸ö×ֶΣ¬Ò»¸öÊÇÓû§Ãû£¬Ò»¸öÊÇÃÜÂ룬ÏÖ½«Õ⸠......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ