Article View: borland.public.delphi.xml
Article #210Too stupid for XPath?
From: Stefan M. Huber
Date: Mon, 23 Jun 2008 10:00
Date: Mon, 23 Jun 2008 10:00
41 lines
2016 bytes
2016 bytes
Hi!
I am trying to use XPath in a D2005 application. But I fail, of course.
The problem is that nodeValue of the selected nodes is always empty.
The test XML string that I read and assign to an xml document is this:
<?xml version="1.0" encoding="iso-8859-15"?>
<root>
<title>title test</title>
<p>paragraph 1</p>
<p>paragraph 2</p>
</root>
Here's the test code that I use:
function getContent(APath: widestring): TXMLTextList; stdcall;
var root : IDOMNodeSelect;
nl : IDOMNodeList;
i : integer;
node : IDOMNode;
begin
_doc := NewXMLDocument;
_doc.Active := true;
_doc.LoadFromXML('<?xml version="1.0"
encoding="iso-8859-15"?><root><title>title test</title><p>paragraph
1</p><p>paragraph 2</p></root>');
root := _doc.DocumentElement.DOMNode as IDOMNodeSelect;
nl := root.selectNodes(APath);
if nl <> nil then
begin
for i := 0 to nl.length - 1 do
begin
ShowMessage(nl.Item[i].nodeName + ': ' + nl.item[i].nodeValue);
end;
end;
end;
Using 'p' as APath parameter, I get two showmessage calls with only 'p: '
as text. Where's the nodeValue?
Stefan
Technical Details
Message-ID:
<op.uc64q8kbs9ddfw@ws-6>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!newsfeed.freenet.de!ecngs!feeder2.ecngs.de!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f5d9b,d44954f9f97a5937,start X-Google-Attributes: gidf5d9b,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 23 Jun 2008 12:00:34 +0200 Subject: Too stupid for XPath? From: "Stefan M. Huber" <looseleaf@gmx.net> Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Newsgroups: borland.public.delphi.xml Content-Transfer-Encoding: 7bit Message-ID: <op.uc64q8kbs9ddfw@ws-6> User-Agent: Opera Mail/9.50 (Win32) NNTP-Posting-Host: 91.113.174.42 X-Trace: newsgroups.borland.com 1214215237 91.113.174.42 (23 Jun 2008 03:00:37 -0700) Lines: 41 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!newsfeed.freenet.de!ecngs!feeder2.ecngs.de!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail