Beispiel #1
0
/* read an xml file into our memory structures and update our view,
   dump any old data we have in memory if we can load a new set */
gboolean missing_read_xml_file(char *fname, GList **list)
{
  /* pointer to the new doc */
  xmlDocPtr doc;
  xmlNodePtr node;

  *list = NULL;
  g_return_val_if_fail(fname!=NULL,FALSE);

  /* parse the new file and put the result into newdoc */
  doc = xmlParseFile(fname);

  /* in case something went wrong */
  if(!doc)
    return FALSE;

  if(/* if there is no root element */
     !doc->children ||
     /* if it doesn't have a name */
     !doc->children->name ||
     /* if it isn't a missing letter node */
     g_ascii_strcasecmp((char *)doc->children->name,"missing_letter")!=0) {
    xmlFreeDoc(doc);
    return FALSE;
  }

  for(node = doc->children->children; node != NULL; node = node->next) {
    if ( g_ascii_strcasecmp((gchar *)node->name, "Board") == 0 )
      add_xml_data(doc, node, list);
  }
  xmlFreeDoc(doc);
  return TRUE;
}
/* ==================================== */
static void parse_doc(xmlDocPtr doc)
{
  xmlNodePtr node;

  for(node = doc->children->children; node != NULL; node = node->next) {
    if ( g_strcasecmp((char *)node->name, "Board") == 0 )
      add_xml_data(doc, node, NULL);
  }

}