The XMLParser class.
More...
#include <XMLParser.h>
|
| | XMLParser (const std::shared_ptr< AuxFunc > &af) |
| | XMLParser constructor.
|
| std::vector< XMLTag > | get_tag (const std::string &book, const std::string &tag_id) |
| | Returns all tags with particular name.
|
| std::string | get_book_encoding (const std::string &book) |
| | Returns XML document encoding.
|
| std::string | get_element_attribute (const std::string &element, const std::string &attr_name) |
| | Returns XML tag attribute if it was found.
|
| std::vector< XMLTag > | listAllTags (const std::string &book) |
| | Parses XML document.
|
| void | searchTag (const std::vector< XMLTag > &list, const std::string &tag_id, std::vector< XMLTag > &result) |
| | Searches tag in tag list.
|
| void | htmlSymbolsReplacement (std::string &book) |
| | Replaces symbols encoded by "&..." sequences.
|
| void | removeAllTags (std::string &book) |
| | Removes all tag elements from XML document.
|
The XMLParser class.
This class contains various methods to process XML documents.
- Deprecated
- This class will be removed in future releases. Use XMLParserCPP library instead.
◆ XMLParser()
| XMLParser::XMLParser |
( |
const std::shared_ptr< AuxFunc > & | af | ) |
|
◆ get_book_encoding()
| std::string XMLParser::get_book_encoding |
( |
const std::string & | book | ) |
|
Returns XML document encoding.
Tries to get XML document header and read encoding from it.
- Parameters
-
| book | XML document content. |
- Returns
- Returns XML document encoding if it was found.
◆ get_element_attribute()
| std::string XMLParser::get_element_attribute |
( |
const std::string & | element, |
|
|
const std::string & | attr_name ) |
Returns XML tag attribute if it was found.
- Parameters
-
| element | tag start element (see XMLTag::element). |
| attr_name | requested attribute name. |
- Returns
- Returns attribute content if it was found.
◆ get_tag()
| std::vector< XMLTag > XMLParser::get_tag |
( |
const std::string & | book, |
|
|
const std::string & | tag_id ) |
Returns all tags with particular name.
This method uses listAllTags() and searchTag() under hood.
- Note
- This method can throw MLException in case of errors.
- Parameters
-
| book | XML document content. |
| tag_id | requested tag name. |
- Returns
- Vector of found tags.
◆ htmlSymbolsReplacement()
| void XMLParser::htmlSymbolsReplacement |
( |
std::string & | book | ) |
|
Replaces symbols encoded by "&..." sequences.
Replaces symbols encoded by "&..." sequences for actual values (see this for details).
- Parameters
-
| book | XML document content symbols to be replaced in. |
◆ listAllTags()
| std::vector< XMLTag > XMLParser::listAllTags |
( |
const std::string & | book | ) |
|
Parses XML document.
Returns all found tags.
- Note
- This method can throw MLException in case of errors.
- Parameters
-
| book | XML document content. |
- Returns
- Vector of found tags.
◆ removeAllTags()
| void XMLParser::removeAllTags |
( |
std::string & | book | ) |
|
Removes all tag elements from XML document.
Simply removes all found XML tag elements and leaves only document content.
- Parameters
-
| book | XML document content. |
◆ searchTag()
| void XMLParser::searchTag |
( |
const std::vector< XMLTag > & | list, |
|
|
const std::string & | tag_id, |
|
|
std::vector< XMLTag > & | result ) |
Searches tag in tag list.
Searches tags in tag list by given tag name.
- Parameters
-
| list | tag list search to be carried out in. |
| tag_id | tag name for tags to be searched. |
| result | vector for results (can be not empty, this methods appends found tags to existing results). |