MSXML的文獻 |
尚未結案
|
a120803
初階會員 ![]() ![]() 發表:61 回覆:66 積分:25 註冊:2003-03-12 發送簡訊給我 |
|
solnone
中階會員 ![]() ![]() ![]() 發表:2 回覆:97 積分:69 註冊:2003-05-06 發送簡訊給我 |
var
DSOControl: Variant;
Node, NewNode: Variant;
NodeList: Variant;
i: integer;
begin
xmldoc := CreateOleObject('Msxml.DOMDocument');
xmldoc.Load('c:\test.xml'); // 載入xml 文件
ShowMessage(xmldoc.xml); // 顯示 xml 文件
Node := xmldoc.selectSingleNode('/*/summary'); //用 XPath 選擇單一 Node
if not VarIsEmpty(Node) then
ShowMessage(Node.text); // 顯示 Node 的 Text
NodeList := xmldoc.selectNodes('/*/summary'); //用 XPath 選擇多個 Node
for i := 0 to NodeList.length -1 do begin
ShowMessage(NodeList.item[i].text); // 顯示 Node 的 Text
end;
NewNode := xmldoc.createElement('newNode'); //建一個 Node
NewNode.text := 'newText';
Node.appendChild(NewNode); // 加入成為 Node 的 child
ShowMessage(xmldoc.xml); // 顯示 xml 文件
xmldoc.save('c:\test2.xml'); // 存檔
end;
|
solnone
中階會員 ![]() ![]() ![]() 發表:2 回覆:97 積分:69 註冊:2003-05-06 發送簡訊給我 |
上面的Delphi文章少了 xmldoc: Variant; 這個變數
再寫BCB的…
做法大部份都相同… DOMDocument, DOMNode, DOMNodeList 的用法去找msxml SDK 或msdn library …
{
Variant XmlDoc = CreateOleObject("Msxml.DOMDocument");
XmlDoc.OleProcedure("Load", "c:/test.xml"); // load xml file
ShowMessage(XmlDoc.OlePropertyGet("xml")); // show xml
Variant rootNode = XmlDoc.OlePropertyGet("documentElement"); // get root Node
ShowMessage(rootNode.OlePropertyGet("xml"));
Variant Node = rootNode.OleFunction("selectSingleNode", "/*/summary"); // selectSingleNode
if (!VarIsEmpty(Node)) {
ShowMessage(Node.OlePropertyGet("text"));
}
}
|
solnone
中階會員 ![]() ![]() ![]() 發表:2 回覆:97 積分:69 註冊:2003-05-06 發送簡訊給我 |
上面的Delphi文章少了 xmldoc: Variant; 這個變數
再寫BCB的…
做法大部份都相同… DOMDocument, DOMNode, DOMNodeList 的用法去找msxml SDK 或msdn library …
{
Variant XmlDoc = CreateOleObject("Msxml.DOMDocument");
XmlDoc.OleProcedure("Load", "c:/test.xml"); // load xml file
ShowMessage(XmlDoc.OlePropertyGet("xml")); // show xml
Variant rootNode = XmlDoc.OlePropertyGet("documentElement"); // get root Node
ShowMessage(rootNode.OlePropertyGet("xml"));
Variant Node = rootNode.OleFunction("selectSingleNode", "/*/summary"); // selectSingleNode
if (!VarIsEmpty(Node)) {
ShowMessage(Node.OlePropertyGet("text"));
}
}
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |