13,825
社区成员
发帖
与我相关
我的任务
分享
#include <XMLDoc.hpp>
#include <msxmldom.hpp>
TXMLDocument *xmlDoc = new TXMLDocument(this);
xmlDoc->LoadFromFile("a.xml");
_di_IXMLDOMNodeRef refNode = xmlDoc->DocumentElement->DOMNode;
_di_IXMLDOMNode root = refNode->GetXMLDOMNode();
if (root!=NULL)
{
_di_IXMLDOMNode n;
root->selectSingleNode("//Config/Base/Ckdp",n);
if (n!=NULL)
{
ShowMessage(n->text);
}
}
delete xmlDoc;
#include <msxmldom.hpp>
#include <XMLDoc.hpp>
#include <xmldom.hpp>
#include <XMLIntf.hpp>
void __fastcall TForm1::btn1Click(TObject *Sender)
{
_di_IXMLDocument XMLDoc = NewXMLDocument();
XMLDoc->LoadFromFile("3.xml");
try{
XMLDoc->Active = true;
}
catch(...)
{
ShowMessage("文件格式出错");
return ;
}
_di_IXMLNode rootdataset = XMLDoc->DocumentElement;
_di_IXMLNodeList NewDataSetNodeList = rootdataset->GetChildNodes();
_di_IXMLNode NewDataSetNode = NewDataSetNodeList->FindNode("Role");
_di_IXMLNodeList NodeList = NewDataSetNode->GetChildNodes();
for(int i=0;i<NodeList->GetCount() ;i++)
{
_di_IXMLNode RowNode = NodeList->Get(i);
_di_IXMLNodeList NodeList1 = RowNode->GetChildNodes();
_di_IXMLNode Node = NodeList1->FindNode("key");
ShowMessage(Node->GetNodeValue());
Node = NodeList1->FindNode("pid");
ShowMessage(Node->GetNodeValue());
}
}
XMLDocument1->LoadFromFile(L"D:\\ccrun\\123.xml");
_di_IXMLDOMNodeRef refNode = XMLDocument1->DocumentElement->DOMNode;
_di_IXMLDOMNode root = refNode->GetXMLDOMNode();
_di_IXMLDOMNodeList NodeList;
root->selectNodes("node1/node2/node3", NodeList);
NodeList = NewDataSetNode->GetChildNodes();
_di_IXMLNode Node = NodeList->FindNode(WideString("PackgType"))