XML::Easy::Text(3pm) | User Contributed Perl Documentation | XML::Easy::Text(3pm) |
XML::Easy::Text - XML parsing and serialisation
use XML::Easy::Text qw( xml10_read_content_object xml10_read_element xml10_read_document xml10_read_extparsedent_object); $content = xml10_read_content_object($text); $element = xml10_read_element($text); $element = xml10_read_document($text); $content = xml10_read_extparsedent_object($text); use XML::Easy::Text qw( xml10_write_content xml10_write_element xml10_write_document xml10_write_extparsedent); $text = xml10_write_content($content); $text = xml10_write_element($element); $text = xml10_write_document($element, "UTF-8"); $text = xml10_write_extparsedent($content, "UTF-8");
This module supplies functions that parse and serialise XML data according to the XML 1.0 specification.
This module is oriented towards the use of XML to represent data for interchange purposes, rather than the use of XML as markup of principally textual data. It does not perform any schema processing, and does not interpret DTDs or any other kind of schema. It adheres strictly to the XML specification, in all its awkward details, except for the aforementioned DTDs.
XML data in memory is represented using a tree of XML::Easy::Content and XML::Easy::Element objects. Such a tree encapsulates all the structure and data content of an XML element or document, without any irrelevant detail resulting from the textual syntax. These node trees are readily manipulated by the functions in XML::Easy::NodeBasics.
The functions of this module are implemented in C for performance, with a pure Perl backup version (which has good performance compared to other pure Perl parsers) for systems that can't handle XS modules.
All functions "die" on error.
These function take textual XML and extract the abstract XML content. In the terminology of the XML specification, they constitute a non-validating processor: they check for well-formedness of the XML, but not for adherence of the content to any schema.
The inputs (to be parsed) for these functions are always character strings. XML text is frequently encoded using UTF-8, or some other Unicode encoding, so that it can contain characters from the full Unicode repertoire. In that case, something must perform UTF-8 decoding (or decoding of some other character encoding) to convert the octets of a file to the characters on which these functions operate. A Perl I/O layer can do the job (see perlio), or it can be performed explicitly using the "decode" function in the Encode module.
Normally one would not want to use this function directly, but prefer the higher-level "xml10_read_document" function. This function exists for the construction of custom XML parsers in situations that don't match the full XML grammar.
The returned array must not be subsequently modified. If possible, it will be marked as read-only in order to prevent modification.
Normally one would not want to use this function directly, but prefer the higher-level "xml10_read_document" function. This function exists for the construction of custom XML parsers in situations that don't match the full XML grammar.
This is the most likely function to use to process incoming XML data. Beware that the encoding declaration in the XML declaration, if any, does not affect the interpretation of the input as a sequence of characters.
This is a relatively obscure part of the XML grammar, used when a subpart of a document is stored in a separate file. You're more likely to require the "xml10_read_document" function.
The returned array must not be subsequently modified. If possible, it will be marked as read-only in order to prevent modification.
These function take abstract XML data and serialise it as textual XML. They do not perform indentation, default attribute suppression, or any other schema-dependent processing.
The outputs of these functions are always character strings. XML text is frequently encoded using UTF-8, or some other Unicode encoding, so that it can contain characters from the full Unicode repertoire. In that case, something must perform UTF-8 encoding (or encoding of some other character encoding) to convert the characters generated by these functions to the octets of a file. A Perl I/O layer can do the job (see perlio), or it can be performed explicitly using the "encode" function in the Encode module.
XML::Easy::NodeBasics, XML::Easy::Syntax, <http://www.w3.org/TR/REC-xml/>
Andrew Main (Zefram) <zefram@fysh.org>
Copyright (C) 2008, 2009 PhotoBox Ltd
Copyright (C) 2009, 2010, 2011, 2017 Andrew Main (Zefram) <zefram@fysh.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2022-10-20 | perl v5.36.0 |