MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlTextReaderReadString

Function xmlTextReaderReadString

ThirdParty/libxml2/vtklibxml2/xmlreader.c:1737–1808  ·  view source on GitHub ↗

* xmlTextReaderReadString: * @reader: the xmlTextReaderPtr used * * Reads the contents of an element or a text node as a string. * * Returns a string containing the contents of the Element or Text node, * or NULL if the reader is positioned on any other type of node. * The string must be deallocated by the caller. */

Source from the content-addressed store, hash-verified

1735 * The string must be deallocated by the caller.
1736 */
1737xmlChar *
1738xmlTextReaderReadString(xmlTextReaderPtr reader)
1739{
1740 xmlNodePtr node, cur;
1741 xmlBufPtr buf;
1742 xmlChar *ret;
1743
1744 if ((reader == NULL) || (reader->node == NULL))
1745 return(NULL);
1746
1747 node = (reader->curnode != NULL) ? reader->curnode : reader->node;
1748 switch (node->type) {
1749 case XML_TEXT_NODE:
1750 case XML_CDATA_SECTION_NODE:
1751 break;
1752 case XML_ELEMENT_NODE:
1753 if ((xmlTextReaderDoExpand(reader) == -1) ||
1754 (node->children == NULL))
1755 return(NULL);
1756 break;
1757 case XML_ATTRIBUTE_NODE:
1758 /* TODO */
1759 break;
1760 default:
1761 break;
1762 }
1763
1764 buf = xmlBufCreateSize(30);
1765 if (buf == NULL) {
1766 xmlTextReaderErrMemory(reader);
1767 return(NULL);
1768 }
1769 xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
1770
1771 cur = node;
1772 while (cur != NULL) {
1773 switch (cur->type) {
1774 case XML_TEXT_NODE:
1775 case XML_CDATA_SECTION_NODE:
1776 xmlBufCat(buf, cur->content);
1777 break;
1778
1779 case XML_ELEMENT_NODE:
1780 if (cur->children != NULL) {
1781 cur = cur->children;
1782 continue;
1783 }
1784 break;
1785
1786 default:
1787 break;
1788 }
1789
1790 if (cur == node)
1791 goto done;
1792
1793 while (cur->next == NULL) {
1794 cur = cur->parent;

Callers

nothing calls this directly

Calls 7

xmlTextReaderDoExpandFunction · 0.85
xmlBufCreateSizeFunction · 0.85
xmlTextReaderErrMemoryFunction · 0.85
xmlBufCatFunction · 0.85
xmlBufDetachFunction · 0.85
xmlBufFreeFunction · 0.85

Tested by

no test coverage detected