On 29/11/2011, Michael Van Canneyt <[email protected]> wrote:
>
> No sweat... DOM is really easy, once you know how it works.


I'm learning. :)

There are  couple of pitfalls obviously, as noted by this post to the
fpc-pascal mailing list.

   http://www.mail-archive.com/[email protected]/msg04796.html

I'm not sure if the difference between Delphi and FPC still exist.

The other tricky thing was the "hidden text node", and the leaf node
that has an "invisible" NodeValue property, but no way of writing that
value out to a XML file.

eg:

    { The FPC DOM way... }
    n := doc.DocumentElement.FirstChild.FirstChild.NodeName;
    v := doc.DocumentElement.FirstChild.FirstChild.FirstChild.NodeValue;
    writeln(Format('n = %s    v = %s', [n, v]));

    { The FPC DOM way... }
    n := doc.DocumentElement.FirstChild.FirstChild.NodeName;
    v := doc.DocumentElement.FirstChild.FirstChild.TextContent;
    writeln(Format('n = %s    v = %s', [n, v]));

I got this now. Both the above examples produce the same output. But
where in the XML is the following stored?

    n := doc.DocumentElement.FirstChild.FirstChild.NodeValue;

This always returns a empty string.

I'm using the following XML sample

---------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<BAIS_XML Version='1.0'>
  <RESPOND ID="BAIS">
    <RESPOND_TIME>2005.01.20 12:26:58</RESPOND_TIME>
  </RESPOND>
  <REQUEST ID="SI1">
    <REQUEST_TIME>2005.01.20 12:26:58</REQUEST_TIME>
  </REQUEST>
  <CONTENT ID="L1">
    <USER ID="simba">
      <GROUP ID="1">Operator bank</GROUP>
      <NAME>Bisma Jayadi</NAME>
      <ALIAS>simba</ALIAS>
      <PASSPORT>FB0woDvKVE4AFQW29a9E</PASSPORT>
    </USER>
    <LOCATION ID="1">
      <CODE>UPPTI.1</CODE>
      <NAME>Komputer Bisma</NAME>
    </LOCATION>
  </CONTENT>
</BAIS_XML>
---------------------------------------


PS:
I also had to Google the meaning or difference between a XML Node and
an XML Element. I hate XML! :)



-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to