Reads a XML term from a text stream.
read_xml/2/3 reads an XML term from the text stream Stream. read_xml(Stream, Term) is equivalent to read_xml(Stream, Term, [ignore_whitespace(true), ignore_comments(true), ignore_processing_instructions(true)]).
When reading an XML term, the following MINERVA term is generated:
document(Header,RootElement,Misc), where Header is a list
of terms describing the prolog of an XML file, RootElement represents
the XML term, and Misc is a list of terms representing the epilog
of an XML file. The prolog may consist of an XML Declaration followed by
comments, whitespaces or processing instructions.
The epilog may consist of comments, processing instructions or whitespace sequences.
A XML Declaration (<?xml ...?>) is converted to the MINERVA
term xml([Attribute=Value, ...]).
A whitespace sequence is converted to the MINERVA term
whitespace(Whitespaces). Whitespace terms will only be generated,
if the option ignore_whitespace is set to false.
A XML comment (<!-- ... -->) will be converted to the MINERVA term
comment(CommentText). Comment terms will only be generated, if
the option ignore_comments is set to false.
A processing instruction (<?name .. ?>) is converted to the
MINERVA term pi(Name, PIContent). Processing instruction terms will
only be generated, if the option ignore_processing_instructions is set to false.
An element body consisting of character data or a CDATA term is converted
to the MINERVA Term chardata(Text).
A XML element is converted to the MINERVA term
element(ElementName, Attributes, SubElements) where ElementName
is the name (markup) of the element, Attributes is a list representing
the attributes of the element (in the form
AttributeName = AttributeValue) and SubElements is a list
representing all subelements of the element.
Whitespaces, Attribute, Value, Text,
CommentText,
Name, PIContent, AttributeName and AttributeValue
are atoms.
Elements of the Options list can be:
ignore_whitespace(+Boolean)
ignore_comments(+Boolean)
ignore_processing_instructions(+Boolean)
where Boolean is true or false
Stream text input stream XmlTerm term representing an XML term Options list of options
open(' hello ', read, Stream, [atom,text]),
read_xml(Stream, Term).
->
Term = document([xml([version = '1.0'])],
element(n1, [a1 = 'x', a2 = 'y'], [
element(n2, [], [chardata('hello')]),
element(n3, [a3 = 'z'], [])]), []).
These predicates are not part of the ISO-Prolog Standard.
| scroll to top |
|