SQLite Forum

XML extension
Login

XML extension

(1) By little-brother on 2021-04-11 14:16:01 [source]

I made a small extension (link) to processing XML. It uses a pugixml-library to parse XML-tree.
There are five scalar functions and one table-valued. Usage examples can be found in the code and in a Wiki.
xml_valid(xml) xml_extract(xml, xpath, sep = "") xml_append(xml, xpath, insertion, pos = after) xml_update(xml, xpath, replacement) xml_remove(xml, xpath) xml_each(xml, xpath)

It looks like XML-format is more dead than alive replaced by json, yaml and protobuf. And parsing XML is not usual in databases too.
But perhaps this extension will be useful to someone.

The extension can be build by mingw like that: g++ -I ../include -shared xml.cpp ../include/pugixml.cpp -o xml.dll -s -static -DPUGIXML_NO_STL -Os

(2) By ddevienne on 2021-04-12 08:57:21 in reply to 1 [link] [source]

Thanks for sharing! I do use XML inside SQLite, so that interesting to me.
Although ATM to do that outside the DB, just storing the XML.

One thing to note though is that pugixml is not Namespace aware.
Namespace prefixes have no meaning in XML processing (except for the xml: one)
and you're on your own with pugixml to get the Namespace URI that really matters.
For multi-Namespaces XML documents, that makes it challenging.

(3) By little-brother on 2021-04-12 22:35:25 in reply to 2 [link] [source]

One thing to note though is that pugixml is not Namespace aware.

I know about this limitation. I choose pugixml because it's a simple to build and simple to use. It seems to me that namespaces are rare case, therefore it can be skipped.

In any case, I have to add this nuance to code and Wiki. Thank you for pointing that out.

(4) By anonymous on 2021-04-12 23:01:24 in reply to 3 [link] [source]

I choose pugixml because it's a simple to build and simple to use. It seems to me that namespaces are rare case, therefore it can be skipped.

That's a matter of perspective, I guess. Namespaces are anything but rare if you're dealing with standardized vocabularies like SVG, XHTML, XMPP, RSS, Atom, OfficeXML, and so on.