Homepage: http://www.gci-net.com/~johnw/emacs.html
Author: John Wiegley
Updated:
Code to efficiently read/write XML data with Elisp
XML is yet another way of expressing recursive, attributed data structures -- something which Lisp has had the capacity to do for decades. The approach taken by xml-parse.el is to read XML data into Lisp structures, and allow those same Lisp structures to be written out as XML. It should facilitate the manipulation and use of XML by Elisp programs. NOTE: This is not a validating parser, and makes no attempt to read DTDs. See psgml.el if you need that kind of power. Also, tags beginning with orMy own book! First John Wiegley It would be parsed into this Lisp structure: '(("book" ("id" . "compiler")) ("bookinfo" ("bookbiblio" ("title" "My own book!") ("edition" "FIrst") ("authorgroup" ("author" ("firstname" "John") ("surname" "Wiegley"))))) ("chapter" ("title" "A very small chapter") ("para" "Wonder where the content is..."))) Now it can easily be modified and interpreted using ordinary Lisp code, without the ordeal of manipulating textual XML. When you're done modifying it, you can write it back out (complete with proper indentation and newlines) using: (insert-xml t) See the documentation for `read-xml' and `insert-xml' for more information. There are also a set of helper functions for accessing parts of a parsed tag: xml-tag-name get the name of a tag xml-tag-attrlist returns a tag's attribute alist xml-tag-attr lookup a specific tag attribute xml-tag-children returns a tag's child list xml-tag-child lookup a specific child tag by name Also, the attribute list and child lists can be searched using `assoc', since they roughly have the same format as an alist. ###autoload A very small chapter Wonder where the content is...