Re: [xml] How can I get this property value?



ex schrieb am 22.08.2010 um 02:23 (-0700):
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";>
 <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"")

Maybe not an option for you (but why not?), however, it would be much
less work evaluating XPath expressions:

  /*/library_geometries/geometry/mesh/source[id="Cube"]/float_array/@count

Or just a part of that long XPath depending on where you are in the
tree. And it could possibly be simplified, but that depends on the
structure of your XML.

For example, if source/@id really were an ID in the XML sense
(uniqueness in the document), you could also use:

  id("Cube")/float_array/@count

-- 
Michael Ludwig



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]