Advertisement
Guest User

xml_sample.c

a guest
Oct 4th, 2010
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.87 KB | None | 0 0
  1. /* This short script shows usage of the XMLFILE object. */
  2. /* See xmlreader.h for a short description of all functions. */
  3. /* Don't modify XMLFILE parameters directly! use at own risk! */
  4. /* - Firoball */
  5.  
  6.  
  7. #include <acknex.h>
  8. #include <default.c>
  9.  
  10.  
  11. #include "..\xmlreader\xmlreader.h"
  12.  
  13. void main ()
  14. {
  15.     video_mode = 7;
  16.     screen_color.blue = 150;
  17.  
  18.  
  19.     STRING* strT = str_create("");
  20.     STRING* strC = str_create("");
  21.     XMLPAR *pParHndl, *pPar;
  22.     XMLATTRIB * pAttrib;
  23.     XMLFILE* pXml = XMLFILE_create("test.xml");
  24.  
  25.     pParHndl = XMLFILE_parse(pXml);
  26.  
  27.     if (pParHndl != NULL)
  28.     {
  29.         /* get XMLPAR by Tag name */
  30.         pPar = XMLPAR_getElementByTag(pParHndl, "LastTag");
  31.    
  32.         /* copy properties into strings and display them */
  33.         XMLPAR_getTag(pPar, strT);
  34.         XMLPAR_getContent(pPar, strC);
  35.         printf("Copy access: %s -> %s", strT->chars, strC->chars);
  36.  
  37.    
  38.         /* get XMLPAR by Tag name */
  39.         pPar = XMLPAR_getElementByTag(pParHndl, "NextTag");
  40.         /* get XMLPAR by Tag index (sub par of pPar) */
  41.         pPar = XMLPAR_getElementByIndex(pPar, 1);
  42.    
  43.         /* get pointers to properties and display them */
  44.         printf("Ptr access: %s -> %s", (XMLPAR_getPTag(pPar))->chars, (XMLPAR_getPContent(pPar))->chars);
  45.  
  46.        
  47.         /* get XMLATTRIB by attribute name */
  48.         pPar = XMLPAR_getElementByTag(pParHndl, "NextTag");
  49.         pAttrib = XMLATTRIB_getElementByAttribute(pPar, "nextattrib");
  50.  
  51.         /* copy properties into strings and display them */
  52.         XMLATTRIB_getAttribute(pAttrib, strT);
  53.         XMLATTRIB_getContent(pAttrib, strC);
  54.         printf("Copy access: %s -> %s", strT->chars, strC->chars);
  55.  
  56.  
  57.         /* get XMLATTRIB by attribute index */
  58.         pAttrib = XMLATTRIB_getElementByIndex(pPar, 0);
  59.        
  60.         /* get pointers to properties and display them */
  61.         printf("Ptr access: %s -> %s", (XMLATTRIB_getPAttribute(pAttrib))->chars, (XMLATTRIB_getPContent(pAttrib))->chars);
  62.     }  
  63.     XMLFILE_remove(pXml);
  64.  
  65.  
  66.     while(1)
  67.     {
  68.         wait(1);
  69.     }  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement