本文整理汇总了C++中Nokogiri_wrap_xml_node函数的典型用法代码示例。如果您正苦于以下问题:C++ Nokogiri_wrap_xml_node函数的具体用法?C++ Nokogiri_wrap_xml_node怎么用?C++ Nokogiri_wrap_xml_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Nokogiri_wrap_xml_node函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: duplicate_node
/*
* call-seq:
* dup
* dup(depth)
* dup(depth, new_parent_doc)
*
* Copy this node.
* An optional depth may be passed in. 0 is a shallow copy, 1 (the default) is a deep copy.
* An optional new_parent_doc may also be passed in, which will be the new
* node's parent document. Defaults to the current node's document.
* current document.
*/
static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
{
VALUE r_level, r_new_parent_doc;
int level;
int n_args;
xmlDocPtr new_parent_doc;
xmlNodePtr node, dup;
Data_Get_Struct(self, xmlNode, node);
n_args = rb_scan_args(argc, argv, "02", &r_level, &r_new_parent_doc);
if (n_args < 1) {
r_level = INT2NUM((long)1);
}
level = (int)NUM2INT(r_level);
if (n_args < 2) {
new_parent_doc = node->doc;
} else {
Data_Get_Struct(r_new_parent_doc, xmlDoc, new_parent_doc);
}
dup = xmlDocCopyNode(node, new_parent_doc, level);
if(dup == NULL) { return Qnil; }
nokogiri_root_node(dup);
return Nokogiri_wrap_xml_node(rb_obj_class(self), dup);
}
开发者ID:Takuya-Yamamot,项目名称:todo_app,代码行数:42,代码来源:xml_node.c
示例2: create_external_subset
/*
* call-seq:
* create_external_subset(name, external_id, system_id)
*
* Create an external subset
*/
static VALUE create_external_subset(VALUE self, VALUE name, VALUE external_id, VALUE system_id)
{
xmlNodePtr node;
xmlDocPtr doc;
xmlDtdPtr dtd;
Data_Get_Struct(self, xmlNode, node);
doc = node->doc;
if(doc->extSubset) {
rb_raise(rb_eRuntimeError, "Document already has an external subset");
}
dtd = xmlNewDtd(
doc,
NIL_P(name) ? NULL : (const xmlChar *)StringValueCStr(name),
NIL_P(external_id) ? NULL : (const xmlChar *)StringValueCStr(external_id),
NIL_P(system_id) ? NULL : (const xmlChar *)StringValueCStr(system_id)
);
if(!dtd) { return Qnil; }
return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
}
开发者ID:Takuya-Yamamot,项目名称:todo_app,代码行数:31,代码来源:xml_node.c
示例3: element_copier
static void element_copier(void *_payload, void *data, xmlChar *name)
{
VALUE hash = (VALUE)data;
xmlNodePtr payload = (xmlNodePtr)_payload;
VALUE element = Nokogiri_wrap_xml_node(Qnil, payload);
rb_hash_aset(hash, NOKOGIRI_STR_NEW2(name), element);
}
开发者ID:00zl00,项目名称:AlfredWorkflow.com,代码行数:9,代码来源:xml_dtd.c
示例4: root
/*
* call-seq:
* root
*
* Get the root node for this document.
*/
static VALUE root(VALUE self)
{
xmlDocPtr doc;
Data_Get_Struct(self, xmlDoc, doc);
xmlNodePtr root = xmlDocGetRootElement(doc);
if(!root) return Qnil;
return Nokogiri_wrap_xml_node(Qnil, root) ;
}
开发者ID:AndreasKrueger,项目名称:nokogiri,代码行数:16,代码来源:xml_document.c
示例5: previous_sibling
/*
* call-seq:
* previous_sibling
*
* Returns the previous sibling node
*/
static VALUE previous_sibling(VALUE self)
{
xmlNodePtr node, sibling;
Data_Get_Struct(self, xmlNode, node);
sibling = node->prev;
if(!sibling) return Qnil;
return Nokogiri_wrap_xml_node(Qnil, sibling);
}
开发者ID:2GenRepo,项目名称:ecosynthetix,代码行数:16,代码来源:xml_node.c
示例6: attr
/*
* call-seq:
* attribute(name)
*
* Get the attribute node with +name+
*/
static VALUE attr(VALUE self, VALUE name)
{
xmlNodePtr node;
xmlAttrPtr prop;
Data_Get_Struct(self, xmlNode, node);
prop = xmlHasProp(node, (xmlChar *)StringValuePtr(name));
if(! prop) return Qnil;
return Nokogiri_wrap_xml_node((xmlNodePtr)prop);
}
开发者ID:jmhodges,项目名称:nokogiri,代码行数:16,代码来源:xml_node.c
示例7: next_sibling
/*
* call-seq:
* next_sibling
*
* Returns the next sibling node
*/
static VALUE next_sibling(VALUE self)
{
xmlNodePtr node, sibling;
Data_Get_Struct(self, xmlNode, node);
sibling = node->next;
if(!sibling) return Qnil;
return Nokogiri_wrap_xml_node(sibling) ;
}
开发者ID:jmhodges,项目名称:nokogiri,代码行数:16,代码来源:xml_node.c
示例8: get_parent
/*
* call-seq:
* parent
*
* Get the parent Node for this Node
*/
static VALUE get_parent(VALUE self)
{
xmlNodePtr node, parent;
Data_Get_Struct(self, xmlNode, node);
parent = node->parent;
if(!parent) return Qnil;
return Nokogiri_wrap_xml_node(parent) ;
}
开发者ID:daustin,项目名称:analysis-xml-processor,代码行数:16,代码来源:xml_node.c
示例9: next_element
/*
* call-seq:
* next_element
*
* Returns the next Nokogiri::XML::Element type sibling node.
*/
static VALUE next_element(VALUE self)
{
xmlNodePtr node, sibling;
Data_Get_Struct(self, xmlNode, node);
sibling = xmlNextElementSibling(node);
if(!sibling) return Qnil;
return Nokogiri_wrap_xml_node(Qnil, sibling);
}
开发者ID:2GenRepo,项目名称:ecosynthetix,代码行数:16,代码来源:xml_node.c
示例10: child
/*
* call-seq:
* child
*
* Returns the child node
*/
static VALUE child(VALUE self)
{
xmlNodePtr node, child;
Data_Get_Struct(self, xmlNode, node);
child = node->children;
if(!child) return Qnil;
return Nokogiri_wrap_xml_node(Qnil, child);
}
开发者ID:2GenRepo,项目名称:ecosynthetix,代码行数:16,代码来源:xml_node.c
示例11: last_element_child
/*
* call-seq:
* last_element_child
*
* Returns the last child node of this node that is an element.
*
* Example:
*
* @doc.root.last_element_child.element? # => true
*/
static VALUE last_element_child(VALUE self)
{
xmlNodePtr node, child;
Data_Get_Struct(self, xmlNode, node);
child = xmlLastElementChild(node);
if(!child) return Qnil;
return Nokogiri_wrap_xml_node(Qnil, child);
}
开发者ID:2GenRepo,项目名称:ecosynthetix,代码行数:20,代码来源:xml_node.c
示例12: previous_element
/*
* call-seq:
* previous_element
*
* Returns the previous Nokogiri::XML::Element type sibling node.
*/
static VALUE previous_element(VALUE self)
{
xmlNodePtr node, sibling;
Data_Get_Struct(self, xmlNode, node);
sibling = node->prev;
if(!sibling) return Qnil;
while(sibling && sibling->type != XML_ELEMENT_NODE)
sibling = sibling->prev;
return sibling ? Nokogiri_wrap_xml_node(Qnil, sibling) : Qnil ;
}
开发者ID:jwagener,项目名称:nokogiri,代码行数:19,代码来源:xml_node.c
示例13: duplicate_node
/*
* call-seq:
* dup
*
* Copy this node
*/
static VALUE duplicate_node(VALUE self)
{
xmlNodePtr node, dup;
Data_Get_Struct(self, xmlNode, node);
dup = xmlCopyNode(node, 1);
if(dup == NULL) return Qnil;
dup->doc = node->doc;
assert(node->parent);
xmlAddChild(node->parent, dup);
return Nokogiri_wrap_xml_node(dup);
}
开发者ID:daustin,项目名称:analysis-xml-processor,代码行数:20,代码来源:xml_node.c
示例14: internal_subset
/*
* call-seq:
* internal_subset
*
* Get the internal subset
*/
static VALUE internal_subset(VALUE self)
{
xmlNodePtr node;
xmlDocPtr doc;
Data_Get_Struct(self, xmlNode, node);
if(!node->doc) return Qnil;
doc = node->doc;
if(!doc->intSubset) return Qnil;
return Nokogiri_wrap_xml_node((xmlNodePtr)doc->intSubset);
}
开发者ID:daustin,项目名称:analysis-xml-processor,代码行数:20,代码来源:xml_node.c
示例15: duplicate_node
/*
* call-seq:
* dup
*
* Copy this node. An optional depth may be passed in, but it defaults
* to a deep copy. 0 is a shallow copy, 1 is a deep copy.
*/
static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
{
VALUE level;
if(rb_scan_args(argc, argv, "01", &level) == 0)
level = INT2NUM(1);
xmlNodePtr node, dup;
Data_Get_Struct(self, xmlNode, node);
dup = xmlDocCopyNode(node, node->doc, NUM2INT(level));
if(dup == NULL) return Qnil;
return Nokogiri_wrap_xml_node(dup);
}
开发者ID:jmhodges,项目名称:nokogiri,代码行数:22,代码来源:xml_node.c
示例16: internal_subset
/*
* call-seq:
* internal_subset
*
* Get the internal subset
*/
static VALUE internal_subset(VALUE self)
{
xmlNodePtr node;
xmlDocPtr doc;
Data_Get_Struct(self, xmlNode, node);
if(!node->doc) return Qnil;
doc = node->doc;
xmlDtdPtr dtd = xmlGetIntSubset(doc);
if(!dtd) return Qnil;
return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
}
开发者ID:jwagener,项目名称:nokogiri,代码行数:21,代码来源:xml_node.c
示例17: previous_element
/*
* call-seq:
* previous_element
*
* Returns the previous Nokogiri::XML::Element type sibling node.
*/
static VALUE previous_element(VALUE self)
{
xmlNodePtr node, sibling;
Data_Get_Struct(self, xmlNode, node);
/*
* note that we don't use xmlPreviousElementSibling here because it's buggy pre-2.7.7.
*/
sibling = node->prev;
if(!sibling) return Qnil;
while(sibling && sibling->type != XML_ELEMENT_NODE)
sibling = sibling->prev;
return sibling ? Nokogiri_wrap_xml_node(Qnil, sibling) : Qnil ;
}
开发者ID:2GenRepo,项目名称:ecosynthetix,代码行数:22,代码来源:xml_node.c
示例18: external_subset
/*
* call-seq:
* external_subset
*
* Get the external subset
*/
static VALUE external_subset(VALUE self)
{
xmlNodePtr node;
xmlDocPtr doc;
xmlDtdPtr dtd;
Data_Get_Struct(self, xmlNode, node);
if(!node->doc) { return Qnil; }
doc = node->doc;
dtd = doc->extSubset;
if(!dtd) { return Qnil; }
return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
}
开发者ID:Takuya-Yamamot,项目名称:todo_app,代码行数:23,代码来源:xml_node.c
示例19: duplicate_node
/*
* call-seq:
* dup
*
* Copy this node. An optional depth may be passed in, but it defaults
* to a deep copy. 0 is a shallow copy, 1 is a deep copy.
*/
static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
{
VALUE level;
xmlNodePtr node, dup;
if(rb_scan_args(argc, argv, "01", &level) == 0)
level = INT2NUM((long)1);
Data_Get_Struct(self, xmlNode, node);
dup = xmlDocCopyNode(node, node->doc, (int)NUM2INT(level));
if(dup == NULL) return Qnil;
NOKOGIRI_ROOT_NODE(dup);
return Nokogiri_wrap_xml_node(rb_obj_class(self), dup);
}
开发者ID:netconstructor,项目名称:nokogiri,代码行数:24,代码来源:xml_node.c
示例20: reparent_node_with
/* :nodoc: */
static VALUE reparent_node_with(VALUE node_obj, VALUE other_obj, node_other_func func)
{
VALUE reparented_obj ;
xmlNodePtr node, other, reparented ;
if(!rb_obj_is_kind_of(node_obj, cNokogiriXmlNode))
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
Data_Get_Struct(node_obj, xmlNode, node);
Data_Get_Struct(other_obj, xmlNode, other);
if(XML_DOCUMENT_NODE == node->type || XML_HTML_DOCUMENT_NODE == node->type)
rb_raise(rb_eArgError, "cannot reparent a document node");
if(node->type == XML_TEXT_NODE) {
NOKOGIRI_ROOT_NODE(node);
node = xmlDocCopyNode(node, other->doc, 1);
}
if (node->doc == other->doc) {
xmlUnlinkNode(node) ;
// TODO: I really want to remove this. We shouldn't support 2.6.16 anymore
if ( node->type == XML_TEXT_NODE
&& other->type == XML_TEXT_NODE
&& is_2_6_16() ) {
// we'd rather leak than segfault.
other->content = xmlStrdup(other->content);
}
if(!(reparented = (*func)(other, node))) {
rb_raise(rb_eRuntimeError, "Could not reparent node (%s:%d)", __FILE__, __LINE__);
}
} else {
xmlNodePtr duped_node ;
// recursively copy to the new document
if (!(duped_node = xmlDocCopyNode(node, other->doc, 1))) {
rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
}
if(!(reparented = (*func)(other, duped_node))) {
rb_raise(rb_eRuntimeError, "Could not reparent node (%s:%d)", __FILE__, __LINE__);
}
xmlUnlinkNode(node);
NOKOGIRI_ROOT_NODE(node);
}
// the child was a text node that was coalesced. we need to have the object
// point at SOMETHING, or we'll totally bomb out.
if (reparented != node) {
DATA_PTR(node_obj) = reparented ;
}
// Appropriately link in namespaces
relink_namespace(reparented);
reparented_obj = Nokogiri_wrap_xml_node(Qnil, reparented);
rb_funcall(reparented_obj, decorate_bang, 0);
return reparented_obj ;
}
开发者ID:jwagener,项目名称:nokogiri,代码行数:64,代码来源:xml_node.c
注:本文中的Nokogiri_wrap_xml_node函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论