Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just starting playing with <code>min-xml</code> too and though I've been extremely frustrated by lack of good examples, I've borrowed and enhanced to give a decent but not perfect example of reading an XML file and seeing all the parts. It shows tag name, attributes, and text values between tags. Not sure how to identify ending tag. Make sure the standard xml tag is at top of xml file. Include <code>stdio</code>, <code>stdlib</code>, <code>string</code> .h files.</p> <pre><code>#include "mxml.h" int main (int argc, char **argv ) { FILE *fp = NULL; int k = 0; mxml_node_t * tree = NULL; mxml_node_t * node = NULL; if (argc &lt; 2){ perror("Argument Required XML File "); exit(1); } fp = fopen (argv[1], "r"); if (fp ){ tree = mxmlLoadFile (NULL , fp , MXML_OPAQUE_CALLBACK); }else { perror("Could Not Open the File Provided"); exit(1); } if (tree){ for (node = mxmlFindElement(tree, tree,NULL,NULL, NULL,MXML_DESCEND); node != NULL; node=mxmlWalkNext (node, NULL, MXML_DESCEND) //node = mxmlFindElement(node, tree, NULL,NULL,NULL,MXML_DESCEND) ){ if (node-&gt;type == MXML_ELEMENT) { printf("MXML_ELEMENT Node &lt;%s&gt;:%d \n", node-&gt;value.element.name, node-&gt;value.element.num_attrs); for (k = 0; k &lt; node-&gt;value.element.num_attrs; k++){ if (node-&gt;value.element.attrs ){ printf ("Attribute Name :: %s \n", node-&gt;value.element.attrs[k].name); printf ("Attribute Value:: %s \n", node-&gt;value.element.attrs[k].value); } //if (!strncmp(node-&gt;value.element.name , "display-name", 12 )){ // printf(" String %s \n", (char*) node-&gt;child-&gt;value.text.string); //} } } else if (node-&gt;type == MXML_REAL){ printf("MXML_REAL Node is %s \n", node-&gt;value.element.name); } else if(node-&gt;type == MXML_OPAQUE){ printf("MXML_OPAQUE Node is %s \n", node-&gt;value.element.name); } else if(node-&gt;type == MXML_INTEGER){ printf("MXML_INTEGER Node is %s \n", node-&gt;value.element.name); } else if(node-&gt;type == MXML_TEXT){ printf("MXML_TEXT Node is %s \n", node-&gt;value.element.name); } else if(node-&gt;type == MXML_IGNORE){ printf("MXML_IGNORE Node is %s \n", node-&gt;value.element.name); } else if(node-&gt;type == MXML_CUSTOM){ printf("MXML_IGNORE Node is %s \n", node-&gt;value.element.name); } else { printf("Type Default Node is %s \n", node-&gt;value.element.name); } } } if (tree){ mxmlDelete(tree); } if (fp){ fclose(fp); } return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload