Difference between revisions of "xmlread"

From Free Pascal wiki
Jump to navigationJump to search
m (Fixed syntax highlighting; deleted category included in page template)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
Provides an XML reader, which can read XML data from a file or stream.
+
{{xmlread}}
The parser can read files encoded in UTF-8, UTF-16 (both endianness),
+
 
and ISO-8859-1. It supports DTD validation.
+
Provides an XML reader, which can read XML data from a file or stream. The data is stored in a [[TXMLDocument]].
Regarding entity references: The pre-defined entities "lt", "gt", "amp", "apos"
+
and "quot", and internal entities declared in DTD, are replaced by their
+
== Declarations ==
defined values during reading. Ability to resolve external entities is
+
 
currently limited to the file system.
+
Declarations excerpted from xmlread.pas.
 +
 
 +
<syntaxhighlight lang=pascal>
 +
procedure ReadXMLFile(out ADoc: TXMLDocument; const AFilename: WideString); overload;
 +
procedure ReadXMLFile(out ADoc: TXMLDocument; var f: Text); overload;
 +
procedure ReadXMLFile(out ADoc: TXMLDocument; var f: TStream); overload;
 +
procedure ReadXMLFile(out ADoc: TXMLDocument; var f: TStream; const ABaseURI: WideString); overload;
 +
 
 +
procedure ReadXMLFragment(AParentNode: TDOMNode; const AFilename: WideString); overload;
 +
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: Text); overload;
 +
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: TStream); overload;
 +
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: TStream; const ABaseURI: WideString); overload;
 +
 
 +
procedure ReadDTDFile(out ADoc: TXMLDocument; const AFilename: WideString); overload;
 +
procedure ReadDTDFile(out ADoc: TXMLDocument; var f: Text); overload;
 +
procedure ReadDTDFile(out ADoc: TXMLDocument; var f: TStream); overload;
 +
procedure ReadDTDFile(out ADoc: TXMLDocument; var f: TStream; const ABaseURI: WideString); overload;
 +
</syntaxhighlight>
 +
 
 +
== Encodings ==
 +
 
 +
The parser can read files encoded in [[UTF-8]], [[UTF-16]] (both endianness), and ISO-8859-1.
 +
 
 +
== White space handling ==
 
Regarding whitespace handling: By default, whitespace directly after the beginning of a
 
Regarding whitespace handling: By default, whitespace directly after the beginning of a
 
tag is discarded, and sections of the XML file which contain only whitespace and
 
tag is discarded, and sections of the XML file which contain only whitespace and
Line 11: Line 34:
 
mode can be enabled by setting TDOMParser.Options.PreserveWhitespace property to
 
mode can be enabled by setting TDOMParser.Options.PreserveWhitespace property to
 
True.
 
True.
 +
 +
== DTD support ==
 +
 +
It supports DTD validation. Regarding entity references: The pre-defined entities "lt", "gt", "amp", "apos" and "quot", and internal entities declared in DTD, are replaced by their defined values during reading. Ability to resolve external entities is currently limited to the file system.
 +
  
 
Back to [[fcl-xml]] overview.
 
Back to [[fcl-xml]] overview.
  
[[Category:XML]]
+
 
 +
== See also ==
 +
 
 +
* [[xmlwrite]]

Latest revision as of 09:09, 3 March 2020

English (en) español (es)

Provides an XML reader, which can read XML data from a file or stream. The data is stored in a TXMLDocument.

Declarations

Declarations excerpted from xmlread.pas.

procedure ReadXMLFile(out ADoc: TXMLDocument; const AFilename: WideString); overload;
procedure ReadXMLFile(out ADoc: TXMLDocument; var f: Text); overload;
procedure ReadXMLFile(out ADoc: TXMLDocument; var f: TStream); overload;
procedure ReadXMLFile(out ADoc: TXMLDocument; var f: TStream; const ABaseURI: WideString); overload;

procedure ReadXMLFragment(AParentNode: TDOMNode; const AFilename: WideString); overload;
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: Text); overload;
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: TStream); overload;
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: TStream; const ABaseURI: WideString); overload;

procedure ReadDTDFile(out ADoc: TXMLDocument; const AFilename: WideString); overload;
procedure ReadDTDFile(out ADoc: TXMLDocument; var f: Text); overload;
procedure ReadDTDFile(out ADoc: TXMLDocument; var f: TStream); overload;
procedure ReadDTDFile(out ADoc: TXMLDocument; var f: TStream; const ABaseURI: WideString); overload;

Encodings

The parser can read files encoded in UTF-8, UTF-16 (both endianness), and ISO-8859-1.

White space handling

Regarding whitespace handling: By default, whitespace directly after the beginning of a tag is discarded, and sections of the XML file which contain only whitespace and no other text content are discarded as well. However, whitespace-preserving mode can be enabled by setting TDOMParser.Options.PreserveWhitespace property to True.

DTD support

It supports DTD validation. Regarding entity references: The pre-defined entities "lt", "gt", "amp", "apos" and "quot", and internal entities declared in DTD, are replaced by their defined values during reading. Ability to resolve external entities is currently limited to the file system.


Back to fcl-xml overview.


See also