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

Function xmlNodeListGetStringInternal

ThirdParty/libxml2/vtklibxml2/tree.c:1528–1592  ·  view source on GitHub ↗

* xmlNodeListGetStringInternal: * @doc: a document (optional) * @node: a node list * @escMode: escape mode (0 = no, 1 = elem, 2 = attr, 3 = raw) * * Returns a pointer to the string. */

Source from the content-addressed store, hash-verified

1526 * Returns a pointer to the string.
1527 */
1528static xmlChar *
1529xmlNodeListGetStringInternal(xmlDocPtr doc, const xmlNode *node, int escMode) {
1530 xmlBufPtr buf;
1531 xmlChar *ret;
1532
1533 if (node == NULL)
1534 return(xmlStrdup(BAD_CAST ""));
1535
1536 if ((escMode == 0) &&
1537 ((node->type == XML_TEXT_NODE) ||
1538 (node->type == XML_CDATA_SECTION_NODE)) &&
1539 (node->next == NULL)) {
1540 if (node->content == NULL)
1541 return(xmlStrdup(BAD_CAST ""));
1542 return(xmlStrdup(node->content));
1543 }
1544
1545 buf = xmlBufCreateSize(64);
1546 if (buf == NULL)
1547 return(NULL);
1548
1549 while (node != NULL) {
1550 if ((node->type == XML_TEXT_NODE) ||
1551 (node->type == XML_CDATA_SECTION_NODE)) {
1552 if (node->content != NULL) {
1553 if (escMode == 0) {
1554 xmlBufCat(buf, node->content);
1555 } else {
1556 xmlChar *encoded;
1557
1558 if (escMode == 1)
1559 encoded = xmlEncodeEntitiesReentrant(doc,
1560 node->content);
1561 else if (escMode == 2)
1562 encoded = xmlEncodeAttributeEntities(doc,
1563 node->content);
1564 else
1565 encoded = xmlEncodeSpecialChars(doc, node->content);
1566 if (encoded == NULL)
1567 goto error;
1568 xmlBufCat(buf, encoded);
1569 xmlFree(encoded);
1570 }
1571 }
1572 } else if (node->type == XML_ENTITY_REF_NODE) {
1573 if (escMode == 0) {
1574 xmlBufGetNodeContent(buf, node);
1575 } else {
1576 xmlBufAdd(buf, BAD_CAST "&", 1);
1577 xmlBufCat(buf, node->name);
1578 xmlBufAdd(buf, BAD_CAST ";", 1);
1579 }
1580 }
1581
1582 node = node->next;
1583 }
1584
1585 ret = xmlBufDetach(buf);

Callers 2

xmlNodeListGetStringFunction · 0.85
xmlNodeListGetRawStringFunction · 0.85

Calls 10

xmlStrdupFunction · 0.85
xmlBufCreateSizeFunction · 0.85
xmlBufCatFunction · 0.85
xmlEncodeSpecialCharsFunction · 0.85
xmlBufGetNodeContentFunction · 0.85
xmlBufAddFunction · 0.85
xmlBufDetachFunction · 0.85
xmlBufFreeFunction · 0.85

Tested by

no test coverage detected