Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
65
Task/XML-XPath/Delphi/xml-xpath-1.delphi
Normal file
65
Task/XML-XPath/Delphi/xml-xpath-1.delphi
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
program XMLXPath;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses ActiveX, MSXML;
|
||||
|
||||
const
|
||||
XML =
|
||||
'<inventory title="OmniCorp Store #45x10^3">' +
|
||||
' <section name="health">' +
|
||||
' <item upc="123456789" stock="12">' +
|
||||
' <name>Invisibility Cream</name>' +
|
||||
' <price>14.50</price>' +
|
||||
' <description>Makes you invisible</description>' +
|
||||
' </item>' +
|
||||
' <item upc="445322344" stock="18">' +
|
||||
' <name>Levitation Salve</name>' +
|
||||
' <price>23.99</price>' +
|
||||
' <description>Levitate yourself for up to 3 hours per application</description>' +
|
||||
' </item>' +
|
||||
' </section>' +
|
||||
' <section name="food">' +
|
||||
' <item upc="485672034" stock="653">' +
|
||||
' <name>Blork and Freen Instameal</name>' +
|
||||
' <price>4.95</price>' +
|
||||
' <description>A tasty meal in a tablet; just add water</description>' +
|
||||
' </item>' +
|
||||
' <item upc="132957764" stock="44">' +
|
||||
' <name>Grob winglets</name>' +
|
||||
' <price>3.56</price>' +
|
||||
' <description>Tender winglets of Grob. Just add water</description>' +
|
||||
' </item>' +
|
||||
' </section>' +
|
||||
'</inventory>';
|
||||
|
||||
var
|
||||
i: Integer;
|
||||
s: string;
|
||||
lXMLDoc: IXMLDOMDocument2;
|
||||
lNodeList: IXMLDOMNodeList;
|
||||
lNode: IXMLDOMNode;
|
||||
lItemNames: array of string;
|
||||
begin
|
||||
CoInitialize(nil);
|
||||
lXMLDoc := CoDOMDocument.Create;
|
||||
lXMLDoc.setProperty('SelectionLanguage', 'XPath');
|
||||
lXMLDoc.loadXML(XML);
|
||||
|
||||
Writeln('First item node:');
|
||||
lNode := lXMLDoc.selectNodes('//item')[0];
|
||||
Writeln(lNode.xml);
|
||||
Writeln('');
|
||||
|
||||
lNodeList := lXMLDoc.selectNodes('//price');
|
||||
for i := 0 to lNodeList.length - 1 do
|
||||
Writeln('Price = ' + lNodeList[i].text);
|
||||
Writeln('');
|
||||
|
||||
lNodeList := lXMLDoc.selectNodes('//item/name');
|
||||
SetLength(lItemNames, lNodeList.length);
|
||||
for i := 0 to lNodeList.length - 1 do
|
||||
lItemNames[i] := lNodeList[i].text;
|
||||
for s in lItemNames do
|
||||
Writeln('Item name = ' + s);
|
||||
end.
|
||||
16
Task/XML-XPath/Delphi/xml-xpath-2.delphi
Normal file
16
Task/XML-XPath/Delphi/xml-xpath-2.delphi
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
First item node:
|
||||
<item upc="123456789" stock="12">
|
||||
<name>Invisibility Cream</name>
|
||||
<price>14.50</price>
|
||||
<description>Makes you invisible</description>
|
||||
</item>
|
||||
|
||||
Price = 14.50
|
||||
Price = 23.99
|
||||
Price = 4.95
|
||||
Price = 3.56
|
||||
|
||||
Item name = Invisibility Cream
|
||||
Item name = Levitation Salve
|
||||
Item name = Blork and Freen Instameal
|
||||
Item name = Grob winglets
|
||||
Loading…
Add table
Add a link
Reference in a new issue