Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <libxml/xmlreader.h>
- static int check (int rc)
- {
- if (rc == -1) {
- fprintf (stderr, "Error from libxml2, fix your code!\n");
- exit (1);
- }
- }
- void main ()
- {
- char *s = "<doc><elem1 att1='foo1' att2='bar1'/><elem2 att1='foo1' att2='bar2'/></doc>";
- xmlTextReaderPtr xml = xmlReaderForMemory (s, strlen(s), NULL, NULL, 0);
- while (check (xmlTextReaderRead (xml))) {
- printf ("%s\n", xmlTextReaderConstName (xml));
- while (check (xmlTextReaderMoveToNextAttribute (xml)))
- printf (" - %s: %s\n", xmlTextReaderConstName (xml), xmlTextReaderConstValue (xml));
- }
- }
- /* Compile with gcc -o attributevalue2 attributevalue2.c `pkg-config --cflags --libs libxml-2.0` */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement