views:

33

answers:

1

For an XML that has

<?xml version="1.0" encoding="utf-8"?>
<COLLADA version="1.4.0" xmlns="http://www.collada.org/2005/11/COLLADASchema"&gt;
 <library_geometries>
  <geometry id="Cube">
   <mesh>
    <source id="Cube">
     <float_array count="24" ">1 2 3</float_array>
[..]

I'm getting properly "1 2 3" string with a

if (!xmlStrcmp(cur_node->name, (const xmlChar *) "mesh")
    printf(": %s\n",xmlNodeGetContent(cur_node->children->next);

But how do I get the value of 'count'? ("count="24"")

e.g.

printf(": %s\n", xmlGetProp(cur_node->children->next,(const xmlChar *)"count"));

isn't right.

+1  A: 

The definition of xmlNodeGetContent is

Read the value of a node, this can be either the text carried directly by this node if it's a TEXT node or the aggregate string of the values carried by this node child's (TEXT and ENTITY_REF). Entity references are substituted.

Thus what's happening is that cur_node->children->next actually points at the <source> node, not the <float_array... node. The call to xmlNodeGetContent appears to work because it's fetching the content from the contained node.

The call to xmlGetProp returns nothing because you're invoking it on the wrong node. You need to ensure that you are invoking xmlGetProp on the correct node.

Jim Garrison