[fpc-pascal] getting XML element's value using dom.pp unit
Bisma Jayadi
bisma at brawijaya.ac.id
Wed Dec 7 14:49:06 CET 2005
Hi all...
I'm currently developing a Lazarus application which need to read an XML file.
In order to do such a task, FPC has provided DOM unit (dom.pp). But, it seems
that dom.pp is unable to read XML element's (text) value. It succesfully read
element's name (through NodeName property) and attributes (name and value)
though. Getting element's name (through NodeValue property) always return an
empty string.
What did I do wrong? Or am I missing something about the dom.pp usage? Here are
the codes I used...
procedure TForm1.Button1Click(Sender: TObject);
var
doc: TXMLDocument;
begin
ReadXMLFile(doc, 'sample.xml');
// this returns correct first attribute's name
Memo1.Lines.Add(doc.DocumentElement.FirstChild.Attributes.Item[0].NodeName);
// this returns correct first attribute's value
Memo1.Lines.Add(doc.DocumentElement.FirstChild.Attributes.Item[0].NodeValue);
// this returns correct first element's name
Memo1.Lines.Add(doc.DocumentElement.FirstChild.FirstChild.NodeName);
// this returns nothing !!!
Memo1.Lines.Add(doc.DocumentElement.FirstChild.FirstChild.NodeValue);
end;
I really appreciate any kind of helps. I thank you in advance.
Regards,
-Bee-
has Bee.ography at
http://beeography.blogsome.com
More information about the fpc-pascal
mailing list