コード例 #1
0
ファイル: droidparser.c プロジェクト: feedcafe/droidparser
/**
 * processNode:
 * @reader: the xmlReader
 *
 * Dump information about the current node
 */
static void processNode(xmlTextReaderPtr reader)
{
	int depth, type;

	type = xmlTextReaderNodeType(reader);
	if ((type == XML_ELEMENT_DECL) || (type == XML_DTD_NODE))
		return;

	depth = xmlTextReaderDepth(reader);

	if ((type == XML_ELEMENT_NODE) && (depth == 2))
		printf("\n");

	if (2 == depth)
		printf("\t");
	else if (3 == depth)
		printf("\t\t");

	xmlNodePtr node = xmlTextReaderCurrentNode(reader);
	if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE && node && node->properties) {
		xmlAttr *attribute = node->properties;
		while (attribute && attribute->name && attribute->children) {
			tag = xmlNodeListGetString(node->doc, attribute->children, 1);
			printf ("%s%c", tag, (depth == 2) ? '\n' : ':');

			bdaddr = strtoba((const char *)tag);
			if (bdaddr)
				add_remote_device(bdaddr);

			attribute = attribute->next;
			/* tag name is what we need */
			break;
		}
	}

	if (xmlTextReaderNodeType(reader) == XML_TEXT_NODE) {
		if (xmlStrstr((xmlChar *)"Service", tag))
			parse_services(reader);
		else if (xmlStrstr((xmlChar *)"HidDescriptor", tag))
			parse_hid_descriptor(reader);
		else if (xmlStrstr((xmlChar *)"HogpRpt", tag))
			parse_hogp(reader);
		else if (xmlStrstr((xmlChar *)"GattAttrs", tag))
			parse_gatt_attribute(reader);
		else if (xmlStrstr((xmlChar *)"DevClass", tag))
			parse_dev_class(reader);
		else if (xmlStrstr((xmlChar *)"Timestamp", tag))
			parse_timestamp(reader);
		else if (xmlStrstr((xmlChar *)"Address", tag))
			parse_bdaddr(reader);
		else
			parse_text_node(reader);
	}
}
コード例 #2
0
static void
handle_default_regex_options_element (ParserState *parser_state)
{
	xmlNode *elm;

	g_return_if_fail (parser_state->error == NULL);

	if (parser_state->ctx_data == NULL)
		return;

	elm = xmlTextReaderCurrentNode (parser_state->reader);

	parser_state->regex_compile_flags = get_regex_flags (elm, 0);
}
コード例 #3
0
string BEXMLTextReader::raw_xml()
{
	xmlBufferPtr node_content = xmlBufferCreate();
	xmlOutputBufferPtr node = (xmlOutputBufferPtr) xmlMalloc ( sizeof(xmlOutputBuffer) );
	memset ( node, 0, (size_t) sizeof(xmlOutputBuffer) );
	node->buffer = node_content;
	
	xmlNodeDumpOutput ( node, xml_document, xmlTextReaderCurrentNode ( reader ), 0, true, "UTF-8" );
	const xmlChar * xml_data = xmlBufferContent ( (xmlBufferPtr)node_content );
	size_t xml_length = xmlBufferLength ( node_content );
	string xml_result ( (char *)xml_data, xml_length );
	
	xmlFree ( (xmlChar *)xml_data );
	
	return xml_result;
} // raw_xml
コード例 #4
0
ファイル: xml_reader.c プロジェクト: halorgium/nokogiri
static int has_attributes(xmlTextReaderPtr reader)
{
  /*
   *  this implementation of xmlTextReaderHasAttributes explicitly includes
   *  namespaces and properties, because some earlier versions ignore
   *  namespaces.
   */
  xmlNodePtr node ;
  node = xmlTextReaderCurrentNode(reader);
  if (node == NULL)
    return(0);

  if ((node->type == XML_ELEMENT_NODE) &&
      ((node->properties != NULL) || (node->nsDef != NULL)))
    return(1);
  return(0);
}
コード例 #5
0
ファイル: ruby_xml_reader.c プロジェクト: astro/libxml-ruby
/*
 * call-seq:
 *    reader.node -> XML::Node
 *
 * Returns the reader's current node.
 * WARNING - Using this method is dangerous because the
 * the node may be destroyed on the next #read.
 */
static VALUE rxml_reader_node(VALUE self)
{
  xmlTextReaderPtr xreader = rxml_text_reader_get(self);
  xmlNodePtr xnode = xmlTextReaderCurrentNode(xreader);
  return rxml_node_wrap(xnode);
}