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

Function xmlNewChild

ThirdParty/libxml2/vtklibxml2/tree.c:2966–3008  ·  view source on GitHub ↗

* xmlNewChild: * @parent: the parent node * @ns: a namespace (optional) * @name: the name of the child * @content: text content with XML references (optional) * * Create a new child element and append it to a parent element. * * If @ns is NULL, the newly created element inherits the namespace * of the parent. * * If provided, @content is expected to be a valid XML attribute * value

Source from the content-addressed store, hash-verified

2964 * are invalid or a memory allocation failed.
2965 */
2966xmlNodePtr
2967xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
2968 const xmlChar *name, const xmlChar *content) {
2969 xmlNodePtr cur, prev;
2970
2971 if ((parent == NULL) || (name == NULL))
2972 return(NULL);
2973
2974 switch (parent->type) {
2975 case XML_DOCUMENT_NODE:
2976 case XML_HTML_DOCUMENT_NODE:
2977 case XML_DOCUMENT_FRAG_NODE:
2978 break;
2979
2980 case XML_ELEMENT_NODE:
2981 if (ns == NULL)
2982 ns = parent->ns;
2983 break;
2984
2985 default:
2986 return(NULL);
2987 }
2988
2989 cur = xmlNewDocNode(parent->doc, ns, name, content);
2990 if (cur == NULL)
2991 return(NULL);
2992
2993 /*
2994 * add the new element at the end of the children list.
2995 */
2996 cur->parent = parent;
2997 if (parent->children == NULL) {
2998 parent->children = cur;
2999 parent->last = cur;
3000 } else {
3001 prev = parent->last;
3002 prev->next = cur;
3003 cur->prev = prev;
3004 parent->last = cur;
3005 }
3006
3007 return(cur);
3008}
3009#endif /* LIBXML_TREE_ENABLED */
3010
3011static void

Callers 2

visitMethod · 0.85
xmlRelaxNGCleanupTreeFunction · 0.85

Calls 1

xmlNewDocNodeFunction · 0.85

Tested by

no test coverage detected