summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2023-09-08 17:23:54 +0300
committerdefanor <defanor@uberspace.net>2023-09-08 17:23:54 +0300
commitaaae19eb8462c784daab0cf9afddc934fdbd1b75 (patch)
tree62e605e8e3c016074b9a62f799d1d638c737405d /examples
parent55db67a6abebeda001feccbbf2b7615d19cb93e5 (diff)
Support libexpat as an alternative XML parser
Diffstat (limited to 'examples')
-rw-r--r--examples/basic.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/examples/basic.c b/examples/basic.c
index 0b77145..528cdf9 100644
--- a/examples/basic.c
+++ b/examples/basic.c
@@ -177,20 +177,11 @@ int main (int argc, char **argv) {
if (strlen(input) != 0) {
if (input[0] == '<' && xml_console) {
/* Raw XML input. */
- xmlDocPtr doc = xmlReadMemory(input, input_len, "", "utf-8", 0);
- if (doc != NULL) {
- xmlNodePtr node_libxml2 = xmlDocGetRootElement(doc);
- if (node_libxml2 != NULL) {
- xmlUnlinkNode(node_libxml2);
- rexmpp_xml_t *node = rexmpp_xml_from_libxml2(node_libxml2);
- xmlFreeNode(node_libxml2);
- rexmpp_send(&s, node);
- } else {
- puts("No root node");
- }
- xmlFreeDoc(doc);
+ rexmpp_xml_t *node = rexmpp_xml_parse(input, input_len);
+ if (node != NULL) {
+ rexmpp_send(&s, node);
} else {
- puts("Failed to read a document");
+ puts("Failed to parse XML");
}
} else if (txt_console) {
rexmpp_console_feed(&s, input, input_len);