Reads a XML term from a text stream....
Move to
Next Prev
Up Top
See also
read_xml/2/3
write_xml/1/2
term2xml/3
term2xmldoc/3
xml2term/3
xmldoc2term/3
IF Computer > MINERVA > Manual > Reference > Predicates > XML (eXtended Markup Language) terms > read_xml/2/3

read_xml/2/3

Reads a XML term from a text stream.

read_xml(+Stream, ?XmlTerm)
read_xml(+Stream, ?XmlTerm, +Options)

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

Arguments

Stream              text input stream
XmlTerm             term representing an XML term
Options             list of options

Examples

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'], [])]), []).

Standard

These predicates are not part of the ISO-Prolog Standard.

See also

read_xml/2/3, write_xml/1/2, term2xml/3, term2xmldoc/3, xml2term/3, xmldoc2term/3.

read on...
MINERVA
ifcomputer logo
f
Expert Services on the Web
Language
English
Japanese
Server
USA
Japan
Site Access
Local Index
Local Contents
Site Contents
Site Index
Printer Friendly
For imode
For PDA
Search
document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/XML/read_xml/home_en.html
published 2008/7/7 update 2001/12/14 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 info@ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
scroll to top managed with ubiCMS