MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlTextReaderGetAttributeNo

Function xmlTextReaderGetAttributeNo

ThirdParty/libxml2/vtklibxml2/xmlreader.c:2310–2350  ·  view source on GitHub ↗

* xmlTextReaderGetAttributeNo: * @reader: the xmlTextReaderPtr used * @no: the zero-based index of the attribute relative to the containing element * * Provides the value of the attribute with the specified index relative * to the containing element. * * Returns a string containing the value of the specified attribute, or NULL * in case of error. The string must be deallocated by the c

Source from the content-addressed store, hash-verified

2308 * in case of error. The string must be deallocated by the caller.
2309 */
2310xmlChar *
2311xmlTextReaderGetAttributeNo(xmlTextReaderPtr reader, int no) {
2312 xmlChar *ret;
2313 int i;
2314 xmlAttrPtr cur;
2315 xmlNsPtr ns;
2316
2317 if (reader == NULL)
2318 return(NULL);
2319 if (reader->node == NULL)
2320 return(NULL);
2321 if (reader->curnode != NULL)
2322 return(NULL);
2323 /* TODO: handle the xmlDecl */
2324 if (reader->node->type != XML_ELEMENT_NODE)
2325 return(NULL);
2326
2327 ns = reader->node->nsDef;
2328 for (i = 0;(i < no) && (ns != NULL);i++) {
2329 ns = ns->next;
2330 }
2331 if (ns != NULL)
2332 return(readerStrdup(reader, ns->href));
2333
2334 cur = reader->node->properties;
2335 if (cur == NULL)
2336 return(NULL);
2337 for (;i < no;i++) {
2338 cur = cur->next;
2339 if (cur == NULL)
2340 return(NULL);
2341 }
2342 /* TODO walk the DTD if present */
2343
2344 if (cur->children == NULL)
2345 return(NULL);
2346 ret = xmlNodeListGetString(reader->node->doc, cur->children, 1);
2347 if (ret == NULL)
2348 xmlTextReaderErrMemory(reader);
2349 return(ret);
2350}
2351
2352/**
2353 * xmlTextReaderGetAttribute:

Callers

nothing calls this directly

Calls 3

readerStrdupFunction · 0.85
xmlNodeListGetStringFunction · 0.85
xmlTextReaderErrMemoryFunction · 0.85

Tested by

no test coverage detected