xmlNodePtr new_xml_node = xmlCopyNode(to_add, 1);
56 if(!new_xml_node)
throwstd::bad_alloc();
59 if(xmlAddChild(parent, new_xml_node) == 0) {
60xmlFreeNode(new_xml_node);
61 throw xml::exception(
"failed to insert xml::node; xmlAddChild failed");
64 if(xmlAddPrevSibling(before, new_xml_node) == 0) {
65xmlFreeNode(new_xml_node);
66 throw xml::exception(
"failed to insert xml::node; xmlAddPrevSibling failed");
69 if(!new_xml_node->ns) new_xml_node->ns = xmlSearchNs(
NULL, parent,
NULL);
76xmlNodePtr copied_node = xmlCopyNode(new_node, 1);
77 if(!copied_node)
throwstd::bad_alloc();
83xmlDocPtr temp_to_test_replace_success = xmlNewDoc((
constxmlChar *)(
"1.0"));
84 if(!temp_to_test_replace_success) {
85xmlFreeNode(copied_node);
86 throwstd::bad_alloc();
90copied_node->doc = temp_to_test_replace_success;
91xmlReplaceNode(old_node, copied_node);
93 if(copied_node->doc == temp_to_test_replace_success) {
94xmlFreeDoc(temp_to_test_replace_success);
95xmlFreeNode(copied_node);
96 throw xml::exception(
"failed to replace xml::node; xmlReplaceNode() failed");
99xmlFreeDoc(temp_to_test_replace_success);
100xmlFreeNode(old_node);
102 if(!copied_node->ns) copied_node->ns = xmlSearchNs(
NULL, copied_node->parent,
NULL);
109xmlNodePtr after = to_erase->next;
111xmlUnlinkNode(to_erase);
112xmlFreeNode(to_erase);
118 if(!
node->ns)
node->ns = default_ns;
123 if(!
node->ns)
node->ns = default_ns;
130 if(!
node||!
node->nsDef)
return false;
131xmlNs * current(
node->nsDef);
133 if(!current->prefix)
return true;
134current = current->next;
140 if(!
node)
return false;
143 if(
node->ns ==
ns)
return true;
146 for(xmlAttrPtr current =
node->properties; current; current = current->next)
147 if(current->ns ==
ns)
return true;
158 if(!
node)
return;
163 if(!
node->ns || !
node->ns->prefix)
171 if(!
node->nsDef)
return;
172 if(
node->nsDef != definition) {
174 while(
prev&&
prev->next != definition)
176 if(!
prev)
return;
177 prev->next = definition->next;
180 node->nsDef = definition->next;
182xmlFreeNs(definition);
186xmlNs *current(
node->nsDef);
188 if(!prefix && !current->prefix)
returncurrent;
189 if(prefix && current->prefix) {
190 if(xmlStrEqual(
reinterpret_cast<constxmlChar*
>(prefix), current->prefix))
193current = current->next;
202xmlNs *current(
node->nsDef);
204 if(!current->prefix)
206current = current->next;
212 if(!
node)
return;
215 if(
node->ns == oldNs)
node->ns = newNs;
218 for(xmlAttrPtr current =
node->properties; current; current = current->next)
219 if(current->ns == oldNs) {
221 if(newNs && newNs->prefix)
This exception class is thrown by xmlwrapp for all runtime XML-related errors along with the xml::par...
The xml::node class is used to hold information about one XML node.
iterator parent(void)
Get an iterator that points at the parent of this node.
The xml::ns class is used to access and handle namespaces of nodes and attributes.
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
This file contains the definition of the xml::exception class.
xmlNodePtr node_replace(xmlNodePtr old_node, xmlNodePtr new_node)
Replace a node with another one.
void erase_ns_definition(xmlNodePtr node, xmlNsPtr definition)
Erases namespace definition in the node.
xmlNsPtr lookup_default_ns_above(xmlNodePtr node)
Searches for a default namspace definition in the given node and above.
xmlNodePtr node_erase(xmlNodePtr to_erase)
Erase a node from the child list, and then free it from memory.
void set_children_default_ns(xmlNodePtr node, xmlNsPtr default_ns)
Set the node and its children default namespace to the given.
void update_children_default_ns(xmlNodePtr node, xmlNsPtr newns)
Replaces the node and its children default namespace with the given.
bool is_ns_used(xmlNodePtr node, xmlNsPtr ns)
Check if the node, attributes and children use the namespace.
void replace_ns(xmlNodePtr node, xmlNsPtr oldNs, xmlNsPtr newNs)
Replaces old namspace with a new one in nodes and attributes all the way down in the hierarchy.
bool has_default_ns_definition(xmlNodePtr node)
Check if the node holds default namespace definition.
xmlNodePtr node_insert(xmlNodePtr parent, xmlNodePtr before, xmlNodePtr to_add)
Insert a node somewhere in the child list of a parent node.
xmlNsPtr lookup_ns_definition(xmlNodePtr node, const char *prefix)
Searches for a namspace definition in the given node.
This file contains the definition of the xml::node manipulation functions.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4