Revision | 590 (tree) |
---|---|
Time | 2022-11-10 04:00:21 |
Author | derekwildstar |
Adicionada uma unit que contém funções utilitárias para o MSXML6
Ainda não foram gerados os projetos para todos os Delphi
@@ -165,7 +165,8 @@ | ||
165 | 165 | KRK.Vcl.Dialogs in '..\..\src\Vcl\KRK.Vcl.Dialogs.pas', |
166 | 166 | KRK.Vcl.Consts in '..\..\src\Vcl\KRK.Vcl.Consts.pas', |
167 | 167 | KRK.Vcl.Dialogs.Editors in '..\..\src\Vcl\KRK.Vcl.Dialogs.Editors.pas', |
168 | - KRK.Rtl.Sys.Console.Utils in '..\..\src\Rtl\Sys\KRK.Rtl.Sys.Console.Utils.pas'; | |
168 | + KRK.Rtl.Sys.Console.Utils in '..\..\src\Rtl\Sys\KRK.Rtl.Sys.Console.Utils.pas', | |
169 | + KRK.Xml.MsXml6.Utilities in '..\..\src\Xml\KRK.Xml.MsXml6.Utilities.pas'; | |
169 | 170 | |
170 | 171 | end. |
171 | 172 |
@@ -190,6 +190,7 @@ | ||
190 | 190 | <DCCReference Include="..\..\src\Vcl\KRK.Vcl.Consts.pas"/> |
191 | 191 | <DCCReference Include="..\..\src\Vcl\KRK.Vcl.Dialogs.Editors.pas"/> |
192 | 192 | <DCCReference Include="..\..\src\Rtl\Sys\KRK.Rtl.Sys.Console.Utils.pas"/> |
193 | + <DCCReference Include="..\..\src\Xml\KRK.Xml.MsXml6.Utilities.pas"/> | |
193 | 194 | <BuildConfiguration Include="Base"> |
194 | 195 | <Key>Base</Key> |
195 | 196 | </BuildConfiguration> |
@@ -0,0 +1,51 @@ | ||
1 | +unit KRK.Xml.MsXml6.Utilities; | |
2 | + | |
3 | +interface | |
4 | + | |
5 | +uses | |
6 | + KRK.Xml.MsXml6; | |
7 | + | |
8 | +function SelectXMLNode(AXMLRoot: IXMLDOMNode; const ANodePath: String): IXMLDOMNode; | |
9 | +function SelectXMLNodes(AXMLRoot: IXMLDOMNode; const ANodePath: String): IXMLDOMNodeList; | |
10 | +function ExtractXMLNode(AXML: String; const ANodePath: String): IXMLDOMNode; | |
11 | +function ExtractXMLNodes(AXML: String; const ANodePath: String): IXMLDOMNodeList; | |
12 | + | |
13 | +implementation | |
14 | + | |
15 | +uses | |
16 | + Winapi.Windows; | |
17 | + | |
18 | +function SelectXMLNode(AXMLRoot: IXMLDOMNode; const ANodePath: String): IXMLDOMNode; | |
19 | +begin | |
20 | + Result := AXMLRoot.selectSingleNode(ANodePath); | |
21 | +end; | |
22 | + | |
23 | +function SelectXMLNodes(AXMLRoot: IXMLDOMNode; const ANodePath: String): IXMLDOMNodeList; | |
24 | +begin | |
25 | + Result := AXMLRoot.selectNodes(ANodePath); | |
26 | +end; | |
27 | + | |
28 | +function ExtractXMLNode(AXML: String; const ANodePath: String): IXMLDOMNode; | |
29 | +var | |
30 | + XMLDOMDocument: IXMLDOMDocument3; | |
31 | +begin | |
32 | + XMLDOMDocument := CoDOMDocument60.Create; | |
33 | + XMLDOMDocument.setProperty('SelectionLanguage','XPath'); | |
34 | + if not XMLDOMDocument.loadXML(AXML) then | |
35 | + OutputDebugString('erro'); | |
36 | + | |
37 | + Result := XMLDOMDocument.selectSingleNode(ANodePath); | |
38 | +end; | |
39 | + | |
40 | +function ExtractXMLNodes(AXML: String; const ANodePath: String): IXMLDOMNodeList; | |
41 | +var | |
42 | + XMLDOMDocument: IXMLDOMDocument3; | |
43 | +begin | |
44 | + XMLDOMDocument := CoDOMDocument60.Create; | |
45 | + XMLDOMDocument.setProperty('SelectionLanguage','XPath'); | |
46 | + XMLDOMDocument.loadXML(AXML); | |
47 | + | |
48 | + Result := XMLDOMDocument.selectNodes(ANodePath); | |
49 | +end; | |
50 | + | |
51 | +end. |