title: Geting xml data using xml parser expat
body: <p>I have managed to parse ok. But now I am having trouble getting the values
  that I need. I can get the element and the attributes. But cannot get the values.
  I would like to get the value of frame in this xml it is 20.</p>
  
  <pre><code>/* track the current level in the xml tree */
  static int depth = 0;
  /* first when start element is encountered */
  void start_element(void *data, const char *element, const char **attribute)
  {
  int i;
  
  for(i = 0; i &lt; depth; i++)
  {
      printf(" ");
  }
  
  printf("%s", element);
  
  for(i = 0; attribute[i]; i += 2)
  {
      printf(" %s= '%s'", attribute[i], attribute[i + 1]);
  }
  
  printf("\n");
  depth++;
  }
  
  /* decrement the current level of the tree */
  void end_element(void *data, const char *el)
  {
  depth--;
  }
  int parse_xml(char *buff, size_t buff_size)
  {
      FILE *fp;
      fp = fopen("start_indication.xml", "r");
      if(fp == NULL)
      {
      printf("Failed to open file\n");
      return 1;
      }
  
      XML_Parser parser = XML_ParserCreate(NULL);
      int done;
      XML_SetElementHandler(parser, start_element, end_element);
  
      memset(buff, 0, buff_size);
      printf("strlen(buff) before parsing: %d\n", strlen(buff));
  
      size_t file_size = 0;
      file_size = fread(buff, sizeof(char), buff_size, fp);
  
      /* parse the xml */
      if(XML_Parse(parser, buff, strlen(buff), XML_TRUE) == XML_STATUS_ERROR)
      {
          printf("Error: %s\n", XML_ErrorString(XML_GetErrorCode(parser)));
      }
  
      fclose(fp);
      XML_ParserFree(parser);
  
      return 0;
  }
  
  
  
  &lt;data&gt;
      &lt;header length="4"&gt;
              &lt;item name="time" type="time"&gt;16&lt;/item&gt;
              &lt;item name="ref" type="string"&gt;3843747&lt;/item&gt;
              &lt;item name="port" type="int16"&gt;0&lt;/item&gt;
              &lt;item name="frame" type="int16"&gt;20&lt;/item&gt;
      &lt;/header&gt;
  &lt;/data&gt;
  
  Output from parsing
  
  
  Element: data
  Element: header length= '4'
  Element: item name= 'time' type= 'time'
  Element: item name= 'ref' type= 'string'
  Element: item name= 'port' type= 'int16'
  Element: item name= 'frame' type= 'int16'
  </code></pre>