当前位置: 首页>>代码示例>>C++>>正文


C++ Nokogiri_wrap_xml_node函数代码示例

本文整理汇总了C++中Nokogiri_wrap_xml_node函数的典型用法代码示例。如果您正苦于以下问题:C++ Nokogiri_wrap_xml_node函数的具体用法?C++ Nokogiri_wrap_xml_node怎么用?C++ Nokogiri_wrap_xml_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Nokogiri_wrap_xml_node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Nokogiri_wrap_xml_node函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。