AXML: 対象TXMLDocumentオブジェクト ANode: nil AXPath: 書き込み先XPath AValue: 書き込む値 AList: 終端がリストの場合Trueを指定、Falseの場合は既にノードが存在する場合上書きされる procedure writeXPath(AXML: TXMLDocument; ANode: IXMLNode; AXPath, AValue: String; AList: Boolean); var i,j: Integer; s,s2: String; n: IXMLNode; begin j:=AnsiPos('/', AXPath); if (j=0) then begin j:=Length(AXPath)+1; end; s:=Copy(AXPath, 1,j-1); s2:=AXPath; Delete(s2, 1, j); if (AXML<>nil) then begin n:=AXML.ChildNodes.FindNode(s); if (n=nil) then begin n:=AXML.AddChild(s); end; end else begin n:=ANode.ChildNodes.FindNode(s); if (n=nil) or ((s2='') and (AList)) then begin n:=ANode.AddChild(s); end; end; if (s2='') then begin n.NodeValue:=AValue;//AnsiToUtf8(AValue); end else begin writeXPath(nil, n, s2, AValue, AList); end; end; |
delphi >