View difference between Paste ID: dt3YnAYx and 6ceYYVWm
SHOW: | | - or go back to the newest paste.
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <libxml/xmlreader.h>
5
6
static int check (int rc)
7
{
8
	if (rc == -1) {
9
		fprintf (stderr, "Error from libxml2, fix your code!\n");
10
		exit (1);
11
	}
12
}
13
14
void main ()
15
{
16-
	char *s = "<!ENTITY bar "bar"><elem att='foo&bar;'/>";
16+
	char *s = "<!ENTITY bar 'bar'><elem att='foo&bar;'/>";
17
	
18
	xmlTextReaderPtr xml = xmlReaderForMemory (s, strlen(s), NULL, NULL, 0);
19
	
20
	while (check (xmlTextReaderRead (xml)) {
21
		printf ("%s\n", xmlTextReaderConstName (xml));
22
		while (check (xmlTextReaderMoveToNextAttribute (xml)) {
23
			while (check (xmlTextReaderReadAttributeValue (xml)) {
24
				printf ("child of attribute with node type %d and value %s\n",
25
					xmlTextReaderNodeType (xml),
26
					xmlTextReaderConstValue (xml));
27
			}
28
		}
29
	}
30
}
31
32
/* Compile with gcc -o attributevalue attributevalue.c `pkg-config --cflags --libs libxml-2.0` */