Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

XmlTag

 

class XmlTag : private Moveable<XmlTag

This class simplifies the task of creating XML output text. It provides means of formatting XML tags and attributes and outputs String.

 

 

Public Method List

 

XmlTag& Tag(const char *s)

Sets the name of tag.

 


 

String operator()()

Returns the completed XML tag block with empty content. E.g. <mytag></mytag>.

 


 

String operator()(const char *text)

String operator()(const String& text)

Returns the completed XML tag block with text content. E.g. <mytag>mytext</mytag>. Note that the text here is not altered in the output in any way - it can contain other subtags.

 


 

String Text(const char *text, byte charset = CHARSET_DEFAULT)

String Text(const String& s, byte charset = CHARSET_DEFAULT)

Returns the completed XML tag block with text content. In this case, text is converted from charset to UTF-8 encoding and escaped with entities.

 


 

String PreservedText(const char *s, byte charset = CHARSET_DEFAULT)

String PreservedText(const String& s, byte charset = CHARSET_DEFAULT)

Returns the completed XML tag block with text content. In this case, text is converted from charset to UTF-8 encoding and escaped with entities. Unlike Text, this variant adds xml:space="preserved" attribute and escapes '\t' and '\n' with entities too.

 


 

XmlTag& operator()(const char *attr, const char *val)

XmlTag& operator()(const char *attr, int q)

XmlTag& operator()(const char *attr, double q)

These methods add XML tag attributes.

 

 

Constructor Detail

 

XmlTag()

Empty constructor. You have to use Tag method to set the tag name.

 


 

XmlTag(const char *tag)

Sets the tag name to tag.

 

 

 

 

XML output functions

 

String DeXml(const char *s, byte charset = CHARSET_DEFAULT, bool escapelf = false)

This function escapes string s encoded in charset with XML entities (like '&lt;') while converting it to UTF-8. If escapelf.is true, '\n' is escaped as '&#x%0a;'.

 


 

String XmlHeader(const char *encoding = "UTF-8", const char *version = "1.0", const char *standalone = NULL)

Creates the header of XML file. If version  is NULL, it is not included, standalone can be either "yes" or "no" or NULL (standalone attribute is then not included).

 


 

String XmlDecl(const char *text)

Creates the declaration element of XML.

 


 

String XmlDocType(const char *text)

Creates the DOCTYPE XML declaration element.

 


 

String XmlDoc(const char *name, const char *xmlbody)

Returns XmlHeader() + XmlDocType(name) + XmlTag(name)(xmlbody) - basically adds standard XML header to XML body.

 


 

String XmlComment(const char *text)

Returns the comment element of XML.

 


 

String XmlPI(const char *text)

Creates the processing info element of XML.

 

 

Last edit by cxl on 01/03/2019. Do you want to contribute?. T++