本文整理汇总了C++中xmlTextReaderNodeType函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlTextReaderNodeType函数的具体用法?C++ xmlTextReaderNodeType怎么用?C++ xmlTextReaderNodeType使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlTextReaderNodeType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TileMapLayer_parse_data
TileMapParseStatus TileMapLayer_parse_data(xmlTextReaderPtr reader,
TileMap *map, TileMapLayer *layer) {
TileMapParseStatus status = TILEMAP_PARSE_OK;
while (xmlTextReaderMoveToNextAttribute(reader)) {
xmlChar *attrName = xmlTextReaderName(reader);
xmlChar *attrVal = xmlTextReaderValue(reader);
if (streq(attrName, "encoding")) {
check(streq(attrVal, "base64"), "Incorrect layer data encoding");
} else if (streq(attrName, "compression")) {
check(streq(attrVal, "gzip"), "Incorrect layer data compression");
}
}
while (xmlTextReaderRead(reader)) {
xmlChar *childName = xmlTextReaderName(reader);
if (xmlTextReaderNodeType(reader) == XML_ELEMENT_DECL &&
streq(childName, "data")) {
break;
} else if (xmlTextReaderNodeType(reader) == XML_TEXT_NODE) {
int tile_count = 0;
extract_gids_from_encoded_data(xmlTextReaderValue(reader),
&(layer->tile_gids), &tile_count);
check(tile_count == map->rows * map->cols, "Inconsistent layer size");
layer->gid_count = tile_count;
}
}
return status;
error:
return TILEMAP_PARSE_INVALID_FORMAT;
}
示例2: parse_properties
static int parse_properties(xmlTextReaderPtr reader, tmx_property **prop_headadr) {
tmx_property *res;
int curr_depth;
const char *name;
curr_depth = xmlTextReaderDepth(reader);
/* Parse each child */
do {
if (xmlTextReaderRead(reader) != 1) return 0; /* error_handler has been called */
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
name = (char*)xmlTextReaderConstName(reader);
if (!strcmp(name, "property")) {
if (!(res = alloc_prop())) return 0;
res->next = *prop_headadr;
*prop_headadr = res;
if (!parse_property(reader, res)) return 0;
} else { /* Unknow element, skip its tree */
if (xmlTextReaderNext(reader) != 1) return 0;
}
}
} while (xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT ||
xmlTextReaderDepth(reader) != curr_depth);
return 1;
}
示例3: cxActionRootLoadCodesWithReader
static void cxActionRootLoadCodesWithReader(cxAny pav,xmlTextReaderPtr reader)
{
cxActionRoot this = pav;
cxReaderAttrInfo *info = cxReaderAttrInfoMake(reader, pav, pav);
while(xmlTextReaderRead(reader) && !this->isError){
if(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT){
continue;
}
cxConstChars temp = cxXMLReadElementName(reader);
if(!ELEMENT_IS_TYPE(cxActionRoot)){
continue;
}
cxObjectReadAttrRun(info);
break;
}
while(xmlTextReaderRead(reader)){
CX_CONTINUE(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT);
cxConstChars id = cxXMLAttr(reader, "id");
CX_CONTINUE(id == NULL);
cxString code = cxXMLReaderReadOuterXml(reader);
cxHashSet(this->codes, cxHashStrKey(id), code);
}
}
示例4: xmlconfig_load_node
static int
xmlconfig_load_node( xmlTextReaderPtr reader )
{
int ret;
const xmlChar *name;
ret = xmlTextReaderRead( reader );
while ( ret == 1 ) {
name = xmlTextReaderConstName( reader );
if ( name &&
(XML_READER_TYPE_END_ELEMENT != xmlTextReaderNodeType( reader )) &&
( 0 == xmlStrncmp( name, (const xmlChar *)"Node", 7 ) ) )
{
const xmlChar *id = xmlTextReaderGetAttribute( reader, (const xmlChar*)"id" );
const xmlChar *nname = xmlTextReaderGetAttribute( reader, (const xmlChar*)"name" );
const xmlChar *type = xmlTextReaderGetAttribute( reader, (const xmlChar*)"type" );
SYSLOG_DEBUG( "xmlconfig_load_node: Name=%s Id=%s Type=%s",
nname, id, type );
ret = zw_node_set_label( atoi((const char*)id), (char *)nname );
if ( ret )
SYSLOG_DEBUG( "xmlconfig_load_node: set label for node(%d) failed %d", atoi((const char*)id), ret );
}
if ( (XML_READER_TYPE_END_ELEMENT == xmlTextReaderNodeType( reader )) &&
(0 == xmlStrncmp(name, (const xmlChar *)"NodeConfig", 10)))
break;
ret = xmlTextReaderRead( reader );
}
return ret;
}
示例5: __attribute__nonnull__
static char *parse_text_element(xmlTextReaderPtr reader, char *name)
{
char *string = NULL;
__attribute__nonnull__(reader);
__attribute__nonnull__(name);
// parse string element attributes here (like xml:lang)
while (xmlTextReaderNextNode(reader)) {
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT &&
!xmlStrcmp(xmlTextReaderConstLocalName(reader), BAD_CAST name)) {
return string;
}
switch (xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_TEXT:
string = (char *)xmlTextReaderValue(reader);
break;
default:
oscap_seterr(OSCAP_EFAMILY_OSCAP, "Unknown XML element in platform");
break;
}
}
return string;
}
示例6: processNode
static void processNode(xmlTextReaderPtr reader, struct osmdata_t *osmdata) {
xmlChar *name;
name = xmlTextReaderName(reader);
if (name == NULL)
name = xmlStrdup(BAD_CAST "--");
switch(xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_ELEMENT:
StartElement(reader, name, osmdata);
if (xmlTextReaderIsEmptyElement(reader))
EndElement(name, osmdata); /* No end_element for self closing tags! */
break;
case XML_READER_TYPE_END_ELEMENT:
EndElement(name, osmdata);
break;
case XML_READER_TYPE_SIGNIFICANT_WHITESPACE:
/* Ignore */
break;
default:
fprintf(stderr, "Unknown node type %d\n", xmlTextReaderNodeType(reader));
break;
}
xmlFree(name);
}
示例7: xmlTextReaderAdvanceToNextStartOrEndElement
static int xmlTextReaderAdvanceToNextStartOrEndElement(xmlTextReaderPtr reader) {
int status = xmlTextReaderRead(reader);
while (status && xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT && xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT) {
status = xmlTextReaderRead(reader);
}
return status;
}
示例8: xmlTextReaderSkipElement
static int xmlTextReaderSkipElement(xmlTextReaderPtr reader) {
int status = xmlTextReaderNext(reader);
while (status && xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT && xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT) {
status = xmlTextReaderRead(reader);
}
return status;
}
示例9: openioc_parse_indicator
static int openioc_parse_indicator(xmlTextReaderPtr reader, struct openioc_hash ** elems)
{
const xmlChar * name;
int rc = CL_SUCCESS;
while (1) {
name = openioc_read(reader);
if (name == NULL)
return rc;
if (xmlStrEqual(name, (const xmlChar *)"Indicator") &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
rc = openioc_parse_indicator(reader, elems);
if (rc != CL_SUCCESS) {
cli_dbgmsg("openioc_parse: openioc_parse_indicator recursion error.\n");
break;
}
} else if (xmlStrEqual(name, (const xmlChar *)"IndicatorItem") &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
rc = openioc_parse_indicatoritem(reader, elems);
if (rc != CL_SUCCESS) {
break;
}
} else if (xmlStrEqual(name, (const xmlChar *)"Indicator") &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
break;
}
}
return rc;
}
示例10: openioc_parse_indicatoritem
static int openioc_parse_indicatoritem(xmlTextReaderPtr reader, struct openioc_hash ** elems)
{
const xmlChar * name;
int rc = CL_SUCCESS;
int context_hash = 0;
while (1) {
name = openioc_read(reader);
if (name == NULL)
break;
if (xmlStrEqual(name, (const xmlChar *)"Context") &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
context_hash = openioc_is_context_hash(reader);
} else if (xmlStrEqual(name, (const xmlChar *)"Content") &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
rc = openioc_parse_content(reader, elems, context_hash);
if (rc != CL_SUCCESS) {
break;
}
} else if (xmlStrEqual(name, (const xmlChar *)"IndicatorItem") &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
break;
}
}
return rc;
}
示例11: xmlconfig_load_timer
static int
xmlconfig_load_timer( xmlTextReaderPtr reader )
{
int ret;
const xmlChar *name;
ret = xmlTextReaderRead( reader );
while ( ret == 1 ) {
name = xmlTextReaderConstName( reader );
if ( name &&
(XML_READER_TYPE_END_ELEMENT != xmlTextReaderNodeType( reader )) &&
( 0 == xmlStrncmp( name, (const xmlChar *)"Timer", 7 ) ) )
{
const xmlChar *nodeid = xmlTextReaderGetAttribute( reader, (const xmlChar*)"node" );
const xmlChar *tname = xmlTextReaderGetAttribute( reader, (const xmlChar*)"name" );
const xmlChar *on = xmlTextReaderGetAttribute( reader, (const xmlChar*)"on" );
const xmlChar *off = xmlTextReaderGetAttribute( reader, (const xmlChar*)"off" );
SYSLOG_DEBUG( "xmlconfig_load_timer: Name=%s Id=%s ON=%s, OFF=%s",
tname, nodeid, on, off );
}
if ( (XML_READER_TYPE_END_ELEMENT == xmlTextReaderNodeType( reader )) &&
(0 == xmlStrncmp(name, (const xmlChar *)"TimerConfig", 11)))
break;
ret = xmlTextReaderRead( reader );
}
return ret;
}
示例12: xmlTextReaderNodeType
const char *oscap_element_string_get(xmlTextReaderPtr reader)
{
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT ||
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ATTRIBUTE)
xmlTextReaderRead(reader);
if (xmlTextReaderHasValue(reader))
return (const char *)xmlTextReaderConstValue(reader);
return NULL;
}
示例13: processNode
/**
* 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);
}
}
示例14: scan
/*
xar_process_subdocument - check TOC for xml subdocument. If found, extract and
scan in memory.
Parameters:
reader - xmlTextReaderPtr
ctx - pointer to cli_ctx
Returns:
CL_SUCCESS - subdoc found and clean scan (or virus found and SCAN_ALL), or no subdocument
other - error return code from cli_mem_scandesc()
*/
static int xar_scan_subdocuments(xmlTextReaderPtr reader, cli_ctx *ctx)
{
int rc = CL_SUCCESS, subdoc_len, fd;
xmlChar * subdoc;
const xmlChar *name;
char * tmpname;
while (xmlTextReaderRead(reader) == 1) {
name = xmlTextReaderConstLocalName(reader);
if (name == NULL) {
cli_dbgmsg("cli_scanxar: xmlTextReaderConstLocalName() no name.\n");
rc = CL_EFORMAT;
break;
}
if (xmlStrEqual(name, (const xmlChar *)"toc") &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT)
return CL_SUCCESS;
if (xmlStrEqual(name, (const xmlChar *)"subdoc") &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
subdoc = xmlTextReaderReadInnerXml(reader);
if (subdoc == NULL) {
cli_dbgmsg("cli_scanxar: no content in subdoc element.\n");
xmlTextReaderNext(reader);
continue;
}
subdoc_len = xmlStrlen(subdoc);
cli_dbgmsg("cli_scanxar: in-memory scan of xml subdocument, len %i.\n", subdoc_len);
rc = cli_mem_scandesc(subdoc, subdoc_len, ctx);
if (rc == CL_VIRUS && SCAN_ALL)
rc = CL_SUCCESS;
/* make a file to leave if --leave-temps in effect */
if(ctx->engine->keeptmp) {
if ((rc = cli_gentempfd(ctx->engine->tmpdir, &tmpname, &fd)) != CL_SUCCESS) {
cli_dbgmsg("cli_scanxar: Can't create temporary file for subdocument.\n");
} else {
cli_dbgmsg("cli_scanxar: Writing subdoc to temp file %s.\n", tmpname);
if (cli_writen(fd, subdoc, subdoc_len) < 0) {
cli_dbgmsg("cli_scanxar: cli_writen error writing subdoc temporary file.\n");
rc = CL_EWRITE;
}
rc = xar_cleanup_temp_file(ctx, fd, tmpname);
}
}
xmlFree(subdoc);
if (rc != CL_SUCCESS)
return rc;
xmlTextReaderNext(reader);
}
}
return rc;
}
示例15: cxHashRootLoadWithReader
cxBool cxHashRootLoadWithReader(cxHashRoot root,xmlTextReaderPtr reader)
{
cxBool ret = false;
while(xmlTextReaderRead(reader)){
if(root->isError){
break;
}
if(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT){
continue;
}
cxConstChars temp = cxXMLReadElementName(reader);
if(ELEMENT_IS_TYPE(cxHashRoot)){
ret = true;
break;
}
}
CX_RETURN(!ret,false);
cxAutoPoolPush();
while(xmlTextReaderRead(reader)){
if(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT){
continue;
}
cxConstChars temp = cxXMLReadElementName(reader);
if(ELEMENT_IS_TYPE(cxDBEnv)){
cxHashRootReadDBEnv(root,reader);
continue;
}
cxConstChars sid = cxXMLAttr(reader, "id");
if(sid == NULL){
CX_WARN("element %s:not set id,data not save to hash table",temp);
continue;
}
cxAny object = NULL;
if(ELEMENT_IS_TYPE(cxString)){
//cxTypesString
object = cxHashRootReadString(root,reader);
}else if(ELEMENT_IS_TYPE(cxHash)){
//cxTypesHash
object = cxHashRootReadHash(root,reader);
}else if(ELEMENT_IS_TYPE(cxArray)){
//cxTypesArray
object = cxHashRootReadArray(root,reader);
}else{
//cxTypesNumber
object = cxHashRootReadNumber(root, temp, reader);
}
if(object != NULL){
cxHashSet(root->items, cxHashStrKey(sid), object);
}
}
cxAutoPoolPop();
return ret;
}