* xmlNewDocNode: * @doc: the target document * @ns: namespace (optional) * @name: the node name * @content: text content with XML references (optional) * * Create an element node. * * If provided, @content is expected to be a valid XML attribute value * possibly containing character and entity references. Syntax errors * and references to undeclared entities are ignored silently. *
| 2140 | * invalid or a memory allocation failed. |
| 2141 | */ |
| 2142 | xmlNodePtr |
| 2143 | xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, |
| 2144 | const xmlChar *name, const xmlChar *content) { |
| 2145 | xmlNodePtr cur; |
| 2146 | xmlChar *copy; |
| 2147 | |
| 2148 | if (name == NULL) |
| 2149 | return(NULL); |
| 2150 | |
| 2151 | if ((doc != NULL) && (doc->dict != NULL)) { |
| 2152 | const xmlChar *dictName = xmlDictLookup(doc->dict, name, -1); |
| 2153 | |
| 2154 | if (dictName == NULL) |
| 2155 | return(NULL); |
| 2156 | return(xmlNewElem(doc, ns, dictName, content)); |
| 2157 | } |
| 2158 | |
| 2159 | copy = xmlStrdup(name); |
| 2160 | if (copy == NULL) |
| 2161 | return(NULL); |
| 2162 | |
| 2163 | cur = xmlNewElem(doc, ns, copy, content); |
| 2164 | if (cur == NULL) { |
| 2165 | xmlFree(copy); |
| 2166 | return(NULL); |
| 2167 | } |
| 2168 | |
| 2169 | return(cur); |
| 2170 | } |
| 2171 | |
| 2172 | /** |
| 2173 | * xmlNewDocNodeEatName: |
no test coverage detected