本文整理汇总了C++中xmlTextReaderRead函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlTextReaderRead函数的具体用法?C++ xmlTextReaderRead怎么用?C++ xmlTextReaderRead使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlTextReaderRead函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkipToEndElement
//
// libxml convenience function
//
static void SkipToEndElement(xmlTextReaderPtr reader)
{
while (xmlTextReaderRead(reader) == 1)
{
if (xmlTextReaderNodeType(reader) == 15)
return;
}
}
示例2: r
bool XmlReader::Read() {
end_element = false;
bool r(xmlTextReaderRead(libxml_stuff->reader) == 1);
while (r) {
int const node_type = xmlTextReaderNodeType(libxml_stuff->reader);
end_element = (node_type == XML_READER_TYPE_END_ELEMENT);
if ((node_type == XML_READER_TYPE_END_ELEMENT)
|| (node_type == XML_READER_TYPE_ELEMENT)
|| (node_type == XML_READER_TYPE_TEXT))
break;
r = (xmlTextReaderRead(libxml_stuff->reader) == 1);
}
return r;
}
示例3: m_relsByType
libvisio::VSDXRelationships::VSDXRelationships(librevenge::RVNGInputStream *input)
: m_relsByType(), m_relsById()
{
if (input)
{
const std::shared_ptr<xmlTextReader> reader(
xmlReaderForStream(input, nullptr, nullptr, XML_PARSE_NOBLANKS|XML_PARSE_NOENT|XML_PARSE_NONET|XML_PARSE_RECOVER),
xmlFreeTextReader);
if (reader)
{
bool inRelationships = false;
int ret = xmlTextReaderRead(reader.get());
while (ret == 1)
{
const xmlChar *name = xmlTextReaderConstName(reader.get());
if (name)
{
if (xmlStrEqual(name, BAD_CAST("Relationships")))
{
if (xmlTextReaderNodeType(reader.get()) == 1)
{
// VSD_DEBUG_MSG(("Relationships ON\n"));
inRelationships = true;
}
else if (xmlTextReaderNodeType(reader.get()) == 15)
{
// VSD_DEBUG_MSG(("Relationships OFF\n"));
inRelationships = false;
}
}
else if (xmlStrEqual(name, BAD_CAST("Relationship")))
{
if (inRelationships)
{
VSDXRelationship relationship(reader.get());
m_relsByType[relationship.getType()] = relationship;
m_relsById[relationship.getId()] = relationship;
}
}
}
ret = xmlTextReaderRead(reader.get());
}
}
}
}
示例4: while
char *xccdf_detect_version_priv(xmlTextReader *reader)
{
while (xmlTextReaderRead(reader) == 1 && xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT);
const struct xccdf_version_info *ver_info = xccdf_detect_version_parser(reader);
if (ver_info == NULL) {
return NULL;
}
return oscap_strdup(xccdf_version_info_get_version(ver_info));
}
示例5: _exml_read
static int _exml_read(EXML *xml, xmlTextReaderPtr reader)
{
int empty;
xmlChar *name, *value;
if (!reader)
return -1;
exml_clear( xml );
while( xmlTextReaderRead( reader ) == 1 ) {
name = xmlTextReaderName(reader);
value = xmlTextReaderValue(reader);
empty = xmlTextReaderIsEmptyElement(reader);
switch( xmlTextReaderNodeType(reader) ) {
case XML_READER_TYPE_ELEMENT:
exml_start(xml);
exml_tag_set(xml, (char *) name);
if (xmlTextReaderHasAttributes(reader)) {
xmlTextReaderMoveToFirstAttribute(reader);
do {
xmlChar *attr_name, *attr_value;
attr_name = xmlTextReaderName(reader);
attr_value = xmlTextReaderValue(reader);
exml_attribute_set(xml, (char *) attr_name, (char *) attr_value);
xmlFree(attr_name);
xmlFree(attr_value);
} while( xmlTextReaderMoveToNextAttribute(reader) == 1 );
}
if (!empty)
break;
case XML_READER_TYPE_END_ELEMENT:
exml_end(xml);
break;
case XML_READER_TYPE_WHITESPACE:
break;
case XML_READER_TYPE_TEXT:
exml_value_set(xml, (char *) value);
break;
}
xmlFree(name);
xmlFree(value);
}
xmlTextReaderClose(reader);
xmlFreeTextReader(reader);
exml_goto_top( xml );
return TRUE;
}
示例6: calloc
static xmlChar *xmlTextReaderReadEntireNodeValue(xmlTextReaderPtr reader) {
xmlChar *buffer = calloc(1, sizeof(xmlChar));
const xmlChar *snippet;
int status;
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ATTRIBUTE) {
return xmlTextReaderValue(reader);
}
else if (xmlTextReaderIsEmptyElement(reader) == 0) {
status = xmlTextReaderRead(reader);
while (status && (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT || xmlTextReaderNodeType(reader) == XML_READER_TYPE_CDATA || xmlTextReaderNodeType(reader) == XML_READER_TYPE_ENTITY_REFERENCE)) {
snippet = xmlTextReaderConstValue(reader);
buffer = realloc(buffer, (xmlStrlen(buffer) + xmlStrlen(snippet) + 1) * sizeof(xmlChar));
xmlStrcat(buffer, snippet);
status = xmlTextReaderRead(reader);
}
}
return buffer;
}
示例7: 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;
}
示例8: xmlTextReaderRead
bool XMLConversion::GetContentInt(int& value)
{
xmlTextReaderRead(_reader);
const xmlChar* pvalue = xmlTextReaderConstValue(_reader);
if(!pvalue)
return false;
value = atoi((const char*)pvalue);
return true;
}
示例9: XmlReader_read
/* @method Boolean XmlReader.read() */
METHOD XmlReader_read(Ctx *ctx, knh_sfp_t *sfp)
{
xmlTextReaderPtr reader = (xmlTextReaderPtr) p_cptr(sfp[0]);
if(reader == NULL) {
KNH_THROWs(ctx, "XmlReader.read(): xmlReader is not readable");
}
int ret = xmlTextReaderRead(reader);
KNH_RETURN_Int(ctx,sfp,ret);
}
示例10: XmlReader_read
//## @Native boolean XmlReader.read();
static KMETHOD XmlReader_read(KonohaContext *kctx, KonohaStack *sfp)
{
xmlTextReaderPtr reader = getRawXmlReader(sfp[0]);
int ret = 0;
if(reader != NULL) {
ret = xmlTextReaderRead(reader);
}
KReturnUnboxValue(ret);
}
示例11: extractFile
/**
* streamFile:
* @filename: the file name to parse
*
* Parse and print information about an XML file.
*
* Returns the resulting doc with just the elements preserved.
*/
static xmlDocPtr
extractFile(const char *filename, const xmlChar *pattern) {
xmlDocPtr doc;
xmlTextReaderPtr reader;
int ret;
/*
* build an xmlReader for that file
*/
reader = xmlReaderForFile(filename, NULL, 0);
if (reader != NULL) {
/*
* add the pattern to preserve
*/
if (xmlTextReaderPreservePattern(reader, pattern, NULL) < 0) {
fprintf(stderr, "%s : failed add preserve pattern %s\n",
filename, (const char *) pattern);
}
/*
* Parse and traverse the tree, collecting the nodes in the process
*/
ret = xmlTextReaderRead(reader);
while (ret == 1) {
ret = xmlTextReaderRead(reader);
}
if (ret != 0) {
fprintf(stderr, "%s : failed to parse\n", filename);
xmlFreeTextReader(reader);
return(NULL);
}
/*
* get the resulting nodes
*/
doc = xmlTextReaderCurrentDoc(reader);
/*
* Free up the reader
*/
xmlFreeTextReader(reader);
} else {
fprintf(stderr, "Unable to open %s\n", filename);
return(NULL);
}
return(doc);
}
示例12: get_vm2vm_from_xml22
/*Read values from XML22 file 读取XML22,虚拟机之间的流量信息文件*/
int get_vm2vm_from_xml22(char *filename)
{
xmlTextReaderPtr reader;
xmlChar *name;
int vd=-1,ret=0;
reader = xmlNewTextReaderFilename(filename);
if (reader != NULL) {
ret = xmlTextReaderRead(reader);
name = xmlTextReaderName(reader);/*获取reader的元素名称*/
if (name == NULL)
name = xmlStrdup(BAD_CAST "--");
/*在这个例子中,我们需要确认文档是正确的类型。“DATA”是在这个示例中使用文档的根类型。*/
if (xmlStrcmp(name, (xmlChar *) "DATA")) {
fprintf(stderr,"document of the wrong type, root node != DATA");
xmlFree(name);
xmlFreeTextReader(reader);
return ret;
}
while (ret == 1) {
process_XML22_Node(reader,&vd);
ret = xmlTextReaderRead(reader);
}
xmlFreeTextReader(reader);
if (ret != 0) {
printf("%s : failed to parse\n", filename);
}
}
else
printf("Unable to open %s\n", filename);
_xpthis->sd->v2v_total=vd+1;/*在全局共享数据区记录v2v的总数*/
return ret;
}
示例13: streamFile
/**
* streamFile:
* @filename: the file name to parse
*
* Parse and print information about an XML file.
*/
static void streamFile (const char *filename) {
xmlTextReaderPtr reader;
int ret;
reader = xmlReaderForFile (filename, NULL, 0);
if (reader != NULL) {
ret = xmlTextReaderRead (reader);
while (ret == 1) {
processNode (reader);
ret = xmlTextReaderRead (reader);
}
xmlFreeTextReader (reader);
if (ret != 0) {
fprintf (stderr, "%s : failed to parse\n", filename);
}
} else {
fprintf (stderr, "Unable to open %s\n", filename);
}
}
示例14: xmlTextReaderRead
void BEXMLTextReader::read ( )
{
int ok = xmlTextReaderRead ( reader );
if ( ok == 0 ) {
last_node = true;
} else if ( ok == kBE_XMLReaderError ) {
throw BEXMLReaderInterface_Exception ( last_error() );
}
}
示例15: EPUB3CopyRootFilePathFromContainer
EXPORT EPUB3Error EPUB3CopyRootFilePathFromContainer(EPUB3Ref epub, char ** rootPath)
{
assert(epub != NULL);
if(epub->archive == NULL) return kEPUB3ArchiveUnavailableError;
static const char *containerFilename = "META-INF/container.xml";
void *buffer = NULL;
uint32_t bufferSize = 0;
uint32_t bytesCopied;
xmlTextReaderPtr reader = NULL;
EPUB3Bool foundPath = kEPUB3_NO;
EPUB3Error error = kEPUB3Success;
error = EPUB3CopyFileIntoBuffer(epub, &buffer, &bufferSize, &bytesCopied, containerFilename);
if(error == kEPUB3Success) {
reader = xmlReaderForMemory(buffer, bufferSize, "", NULL, XML_PARSE_RECOVER);
if(reader != NULL) {
int retVal;
while((retVal = xmlTextReaderRead(reader)) == 1)
{
const char *rootFileName = "rootfile";
const xmlChar *name = xmlTextReaderConstLocalName(reader);
if(xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT && xmlStrcmp(name, BAD_CAST rootFileName) == 0) {
xmlChar *fullPath = xmlTextReaderGetAttribute(reader, BAD_CAST "full-path");
if(fullPath != NULL) {
// TODD: validate that the full-path attribute is of the form path-rootless
// see http://idpf.org/epub/30/spec/epub30-ocf.html#sec-container-metainf-container.xml
foundPath = kEPUB3_YES;
*rootPath = strdup((char *)fullPath);
} else {
// The spec requires the full-path attribute
error = kEPUB3XMLXDocumentInvalidError;
}
break;
}
}
if(retVal < 0) {
error = kEPUB3XMLParseError;
}
if(!foundPath) {
error = kEPUB3XMLXElementNotFoundError;
}
} else {
error = kEPUB3XMLReadFromBufferError;
}
EPUB3_FREE_AND_NULL(buffer);
}
xmlFreeTextReader(reader);
return error;
}