Talk:XML Tutorial

From Lazarus wiki
Revision as of 10:02, 13 October 2013 by Nsunny (talk | contribs) (writeXMLFile bug)
Jump to navigationJump to search

Docelement is not the root of XML tree in DOM

The first sample has

   ReadXMLFile(Doc, 'test.xml');
   PassNode := Doc.DocumentElement.FindNode('password');

Does this mean that DocumentElement is the representation of the top of the XML document in DOM form? Can you also write to that to e.g. change <?xml version="1.0"?> to <?xml version="1.0" standalone="yes"?>

--BigChimp 09:36, 24 July 2011 (CEST)

No, the top of XML document is represented by the Document object itself. DocumentElement is a regular TDOMElement object, which is a child of Document. The reason of having a separate DocumentElement property is that the document may contain comments and processing instructions before and after the root element, and it also may contain a DTD node, so condition DocumentElement=Document.FirstChild is not always true.

The XML declaration <?xml version="1.0"?> is not a part of node tree. DOM specification levels 1 and 2 do not provide any means to modify it, but DOM level 3 introduces Document.xmlVersion, Document.xmlEncoding and Document.xmlStandalone properties for this purpose. xmlStandalone is not yet implemented by fcl-xml.

Gorelkin 09:11, 25 July 2011 (CEST)

Thanks! This clears it up! --BigChimp 14:04, 26 July 2011 (CEST)

Required uses clauses - seems fixed?

The example routines, taken "as is", does not compile. Need to tell what units are needed in the uses section, at least (no, I don't know what they are) --Kormoran 14:19, 26 March 2011 (CET)

The writeXMLFile example does not work unless laz2_XMLWrite is used

I am using Lazarus 1.0.10 (FPC 2.6.2) on Windows 7. First I tried the example code as is, but it did not work. But when I used the laz2_* equivalents, it worked.