本文整理汇总了C++中xmlUnlinkNode函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlUnlinkNode函数的具体用法?C++ xmlUnlinkNode怎么用?C++ xmlUnlinkNode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlUnlinkNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cleanup_xml_node
/* removes all empty text, comments and other insignoficant nodes */
static void cleanup_xml_node(xmlNodePtr node)
{
xmlNodePtr trav;
xmlNodePtr del = NULL;
trav = node->children;
while (trav != NULL) {
if (del != NULL) {
xmlUnlinkNode(del);
xmlFreeNode(del);
del = NULL;
}
if (trav->type == XML_TEXT_NODE) {
if (is_blank(trav->content)) {
del = trav;
}
} else if ((trav->type != XML_ELEMENT_NODE) &&
(trav->type != XML_CDATA_SECTION_NODE)) {
del = trav;
} else if (trav->children != NULL) {
cleanup_xml_node(trav);
}
trav = trav->next;
}
if (del != NULL) {
xmlUnlinkNode(del);
xmlFreeNode(del);
}
}
示例2: real_run_at_node
/*
* Interprets nodes from @topnode and for all of @topnode's next siblings
*/
static gboolean
real_run_at_node (GdaReportEngine *engine, xmlNodePtr topnode, RunContext *context, GError **error)
{
xmlNodePtr node;
xmlNodePtr next_node = NULL;
for (node = topnode; node; node = next_node) {
next_node = node->next;
if (!strncmp ((gchar *) node->name, "gda_report", 10)) {
GSList *created_nodes = NULL;
gboolean cmd_res = TRUE;
gsize i;
gboolean command_found = FALSE;
for (i = 0; i < sizeof (commands) / sizeof (EngineCommand); i++) {
EngineCommand *ec = (EngineCommand *) &(commands [i]);
if (ec->has_prefix) {
if (!strcmp (((gchar *) node->name) + 10, ec->tag_name + 10)) {
command_found = TRUE;
if (ec->func)
cmd_res = (ec->func) (engine, node, &created_nodes, context, error);
break;
}
}
}
if (!command_found) {
/* gda_ node not implemented */
TO_IMPLEMENT;
g_warning ("Engine command '%s' is not yet implemented", (gchar *) node->name);
}
if (created_nodes) {
/* put @node's contents before @node */
GSList *list;
for (list = created_nodes; list; list = list->next) {
next_node = xmlAddPrevSibling (node, (xmlNodePtr) list->data);
g_assert (next_node);
}
g_slist_free (created_nodes);
/* destroy @node */
xmlUnlinkNode (node);
xmlFreeNode (node);
next_node = next_node->next;
}
else {
/* destroy @node */
xmlUnlinkNode (node);
xmlFreeNode (node);
}
if (!cmd_res)
return FALSE;
}
else if (node->children) {
if (!real_run_at_node (engine, node->children, context, error))
return FALSE;
}
}
return TRUE;
}
示例3: gda_report_engine_set_property
static void
gda_report_engine_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
GdaReportEngine *eng;
eng = GDA_REPORT_ENGINE (object);
if (eng->priv) {
switch (param_id) {
case PROP_SPEC_NODE: {
if (eng->priv->spec) {
xmlFreeNode (eng->priv->spec);
eng->priv->spec = NULL;
}
eng->priv->spec = g_value_get_pointer (value);
break;
}
case PROP_SPEC_STRING: {
xmlDocPtr doc;
doc = xmlParseDoc (BAD_CAST g_value_get_string (value));
if (doc) {
if (eng->priv->spec)
xmlFreeNode (eng->priv->spec);
eng->priv->spec = xmlDocGetRootElement (doc);
xmlUnlinkNode (eng->priv->spec);
if (eng->priv->doc)
xmlFreeDoc (eng->priv->doc);
eng->priv->doc = doc;
}
break;
}
case PROP_SPEC_FILE: {
xmlDocPtr doc;
doc = xmlParseFile (g_value_get_string (value));
if (doc) {
if (eng->priv->spec)
xmlFreeNode (eng->priv->spec);
eng->priv->spec = xmlDocGetRootElement (doc);
xmlUnlinkNode (eng->priv->spec);
if (eng->priv->doc)
xmlFreeDoc (eng->priv->doc);
eng->priv->doc = doc;
}
break;
}
case PROP_OUTPUT_DIR:
g_free (eng->priv->output_dir);
eng->priv->output_dir = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
}
示例4: while
void Editor_Export::processNoteCitation (xmlNodePtr node)
{
// Remove the note citation from the text.
xmlNodePtr child = node->xmlChildrenNode;
while (child != NULL) {
xmlNodePtr cache = child;
child = child->next;
xmlUnlinkNode (cache);
xmlFree (cache);
}
// Get more information about the footnote to retrieve.
string href;
string id;
xmlChar * property = xmlGetProp (node, BAD_CAST "href");
if (property) {
href = (char *) property;
xmlFree (property);
id = href.substr (1);
}
// Sample footnote body.
// <p class="x"><a href="#citation1" id="note1">x</a><span> </span><span>+ 2 Joh. 1.1</span></p>
// Retrieve the <a> element from it.
// At first this was done through an XPath expression:
// http://www.grinninglizard.com/tinyxml2docs/index.html
// But XPath crashes on Android.
// Therefore now it iterates of all the nodes to find the required <a> element.
xmlNodePtr aElement = get_note_pointer (xmlDocGetRootElement (document), id);
if (aElement) {
// It now has the 'a' element: Get its 'p' parent, and then remove that 'a' element.
// So we remain with:
// <p class="x"><span> </span><span>+ 2 Joh. 1.1</span></p>
xmlNodePtr pElement = aElement->parent;
xmlUnlinkNode (aElement);
xmlFree (aElement);
// Preserve active character styles in the main text, and reset them for the note.
vector <string> preservedCharacterStyles = characterStyles;
characterStyles.clear();
// Process this 'p' element.
processingNote = true;
processNode (pElement);
processingNote = false;
// Restore the active character styles for the main text.
characterStyles = preservedCharacterStyles;
// Remove this element so it can't be processed again.
xmlUnlinkNode (pElement);
xmlFree (pElement);
} else {
Database_Logs::log ("Discarding note with id " + id + " and href " + href);
}
}
示例5: html_search_for_tables
/*
* Handles incomplete html fragments as may occur on the clipboard,
* e.g. a <td> without <tr> and <table> in front of it.
*/
static void
html_search_for_tables (htmlNodePtr cur, htmlDocPtr doc,
WorkbookView *wb_view, GnmHtmlTableCtxt *tc)
{
htmlNodePtr ptr;
if (cur == NULL) {
xmlGenericError(xmlGenericErrorContext,
"htmlNodeDumpFormatOutput : node == NULL\n");
return;
}
if (cur->type != XML_ELEMENT_NODE)
return;
if (xmlStrEqual (cur->name, CC2XML ("table"))) {
html_read_table (cur, doc, wb_view, tc);
} else if (starts_inferred_table (cur) || starts_inferred_row (cur)) {
htmlNodePtr tnode = xmlNewNode (NULL, "table");
/* Link in a table node */
xmlAddPrevSibling (cur, tnode);
if (starts_inferred_row (cur)) {
htmlNodePtr rnode = xmlNewNode (NULL, "tr");
/* Link in a row node */
xmlAddChild (tnode, rnode);
/* Make following elements children of the row node,
* until we meet one which isn't legal in a row. */
while ((ptr = tnode->next) != NULL) {
if (ends_inferred_row (ptr))
break;
xmlUnlinkNode (ptr);
xmlAddChild (rnode, ptr);
}
}
/* Make following elements children of the row node,
* until we meet one which isn't legal in a table. */
while ((ptr = tnode->next) != NULL) {
if (ends_inferred_table (ptr))
break;
xmlUnlinkNode (ptr);
xmlAddChild (tnode, ptr);
}
html_read_table (tnode, doc, wb_view, tc);
} else {
for (ptr = cur->children; ptr != NULL ; ptr = ptr->next) {
html_search_for_tables (ptr, doc, wb_view, tc);
/* ptr may now have been pushed down in the tree,
* if so, ptr->next is not the right pointer to
* follow */
while (ptr->parent != cur)
ptr = ptr->parent;
}
}
}
示例6: xmlCopyNode
void XMLElement::setChildren(const XMLElement & elem) const
{
xmlNode *n = elem.getRealNode();
if (n && n->parent != node)
{
xmlNode *cpy = xmlCopyNode(n, 1);
xmlUnlinkNode(cpy);
xmlUnlinkNode(node->children);
xmlFreeNodeList(node->children);
node->children = 0;
xmlAddChild(node, cpy);
}
}
示例7: rxml_node_remove_ex
static VALUE rxml_node_remove_ex(VALUE self)
{
xmlNodePtr xnode, xresult;
xnode = rxml_get_xnode(self);
/* First unlink the node from its parent. */
xmlUnlinkNode(xnode);
/* Now copy the node we want to remove and make the
current Ruby object point to it. We do this because
a node has a number of dependencies on its parent
document - its name (if using a dictionary), entities,
namespaces, etc. For a node to live on its own, it
needs to get its own copies of this information.*/
xresult = xmlDocCopyNode(xnode, NULL, 1);
/* Now free the original node. */
xmlFreeNode(xnode);
/* Now wrap the new node */
RDATA(self)->data = xresult;
xresult->_private = (void*) self;
/* Now return the removed node so the user can
do something with it.*/
return self;
}
示例8: xmlUnlinkNode
/*Remove - removes element from xml tree*/
void CXMLElement::Remove()
{
if (!isinited()) return;
xmlUnlinkNode(element);
xmlFreeNode(element);
element = NULL;
}
示例9: switch
bool gpl::xml::eraseNodeByXPath()
{
if (m_xml->resource == NULL)
return false;
//cout<<"resource->type:"<<m_xml->resource->type<<endl;
switch (m_xml->resource->type)
{
case XPATH_NODESET://Object is a Node Set
if (m_xml->resource->nodesetval == NULL)
return false;
xmlNodePtr cur;
//取得第一个节点
if ((cur = (*(m_xml->resource->nodesetval->nodeTab))) == NULL)
return true;
xmlUnlinkNode(cur);
xmlFreeNode(cur);
cur = NULL;
break;
case XPATH_XSLT_TREE://Object is an XSLT value tree
case XPATH_BOOLEAN://Object is a Boolean
case XPATH_NUMBER://Object is a number
case XPATH_STRING://Object is a string
case XPATH_POINT://Object is a point
case XPATH_RANGE://是一个范围
case XPATH_LOCATIONSET://Object is a Location Set
case XPATH_USERS://Object is user defined
case XPATH_UNDEFINED://Object is uninitialized
return false;
break;
}
return true;
}
示例10: xmlNodeGetContent
void
Local::Presentity::rename_group (const std::string old_name,
const std::string new_name)
{
bool old_name_present = false;
bool already_in_new_name = false;
std::set<xmlNodePtr> nodes_to_remove;
/* remove the old name's node
* and check if we aren't already in the new name's group
*/
for (xmlNodePtr child = node->children ;
child != NULL ;
child = child->next) {
if (child->type == XML_ELEMENT_NODE
&& child->name != NULL) {
if (xmlStrEqual (BAD_CAST ("group"), child->name)) {
xmlChar* xml_str = xmlNodeGetContent (child);
if (xml_str != NULL) {
if (!xmlStrcasecmp ((const xmlChar*)old_name.c_str (), xml_str)) {
nodes_to_remove.insert (child); // don't free what we loop on!
old_name_present = true;
}
if (!xmlStrcasecmp ((const xmlChar*)new_name.c_str (), xml_str)) {
already_in_new_name = true;
}
xmlFree (xml_str);
}
}
}
}
// ok, now we can clean up!
for (std::set<xmlNodePtr>::iterator iter = nodes_to_remove.begin ();
iter != nodes_to_remove.end ();
++iter) {
xmlUnlinkNode (*iter);
xmlFreeNode (*iter);
}
if (old_name_present && !already_in_new_name) {
xmlNewChild (node, NULL,
BAD_CAST "group",
BAD_CAST robust_xmlEscape (node->doc,
new_name).c_str ());
}
updated ();
trigger_saving ();
}
示例11: delete_eag_onelevel
/*delete one level xml node*/
int delete_eag_onelevel(char *fpath,char *node_name,char *attribute,char *ruler)
{
xmlDocPtr pdoc = NULL;
xmlNodePtr pcurnode = NULL;
char *psfilename;
int flag=-1;
psfilename = fpath;
pdoc = xmlReadFile(psfilename,"utf-8",256);
if(NULL == pdoc)
{
return 1;
}
pcurnode = xmlDocGetRootElement(pdoc);
pcurnode = pcurnode->xmlChildrenNode;
xmlNodePtr propNodePtr = pcurnode;
while (NULL != pcurnode)
{
if (!xmlStrcmp(pcurnode->name, BAD_CAST node_name))
{
propNodePtr = pcurnode;
xmlChar* szAttr = xmlGetProp(propNodePtr,BAD_CAST attribute);
if(!xmlStrcmp(szAttr,BAD_CAST ruler))
{
xmlNodePtr tempNode;
tempNode = pcurnode->next;
xmlUnlinkNode(pcurnode);
xmlFreeNode(pcurnode);
pcurnode = tempNode;
flag=0;
continue;
}
xmlFree(szAttr);
}
pcurnode = pcurnode->next;
}
xmlSaveFile(fpath,pdoc);
return flag;
}
示例12: remove_doc_from_content_list
static void remove_doc_from_content_list(xmlNodePtr cl_node, struct IdTab *id_tab,
int start, int end)
{
xmlNodePtr node, next;
char *str_id;
int id, i;
if (cl_node == NULL)
return;
for(node = cl_node; node != NULL; node = next)
{
next = node->next;
if (node->type == XML_ELEMENT_NODE &&
!xmlStrcmp(node->name, (xmlChar *)"doc"))
{
str_id = (char *)xmlGetProp(node, (xmlChar *)"docid");
id = atoi(str_id);
xmlFree(str_id);
for(i = start; id_tab[i].id != id && i < end; i++)
;
if (i < end && id_tab[i].id == id)
{
xmlUnlinkNode(node);
xmlFreeNode((void *)node);
}
}
else
remove_doc_from_content_list(node->children, id_tab, start, end);
}
}
示例13: command_gda_report_iter_run
/*
* COMMAND: <gda_report_section>
*
* Creates copies of its contents, one copy per row in the new run context's
* data model.
*
* uses node's contents: yes
* requested attributes: none
*
* REM: either "query_name" or a <gda_report_query> sub node must be provided to create a data model.
*/
static gboolean
command_gda_report_iter_run (GdaReportEngine *engine, xmlNodePtr node, GSList **created_nodes,
RunContext *context, GError **error)
{
if (!context || !context->iter)
return TRUE;
gda_data_model_iter_move_next (context->iter);
while (gda_data_model_iter_is_valid (context->iter)) {
xmlNodePtr dup, child;
dup = xmlCopyNode (node, 1);
if (!real_run_at_node (engine, dup->children, context, error)) {
xmlFreeNode (dup);
return FALSE;
}
else {
for (child = dup->children; child; child = dup->children) {
xmlUnlinkNode (child);
*created_nodes = g_slist_prepend (*created_nodes, child);
}
}
xmlFreeNode (dup);
gda_data_model_iter_move_next (context->iter);
}
*created_nodes = g_slist_reverse (*created_nodes);
return TRUE;
}
示例14: xmlUnlinkNodeWithCheck
int xmlUnlinkNodeWithCheck(xmlNode *node) {
if (xmlNodePtrCheck(node->parent)) {
xmlUnlinkNode(node);
return 1;
}
return 0;
}
示例15: rxml_node_content_add
/*
* call-seq:
* curr_node << "Some text"
* curr_node << node
*
* Add the specified text or XML::Node as a new child node to the
* current node.
*
* If the specified argument is a string, it should be a raw string
* that contains unescaped XML special characters. Entity references
* are not supported.
*
* The method will return the current node.
*/
static VALUE rxml_node_content_add(VALUE self, VALUE obj)
{
xmlNodePtr xnode;
VALUE str;
Data_Get_Struct(self, xmlNode, xnode);
/* XXX This should only be legal for a CDATA type node, I think,
* resulting in a merge of content, as if a string were passed
* danj 070827
*/
if (rb_obj_is_kind_of(obj, cXMLNode))
{
xmlNodePtr xtarget;
Data_Get_Struct(obj, xmlNode, xtarget);
xmlUnlinkNode(xtarget);
rxml_node_modify_dom(self, obj, xmlAddChild);
}
else
{
str = rb_obj_as_string(obj);
if (NIL_P(str) || TYPE(str) != T_STRING)
rb_raise(rb_eTypeError, "invalid argument: must be string or XML::Node");
xmlNodeAddContent(xnode, (xmlChar*) StringValuePtr(str));
}
return self;
}