> I've found the XML libs I've used to be cumbersome, too. I think they can
be
> less so if we look at them more as extensions to a filesystem (file and
> directory) paradigm. I need to scheme further on this, though.
The only substantial difference I can think of between XML and filesystem
plus "stat" attributes is that order of child elements is significant. Thus,
the interface could be handled just like a filesystem except with the
addition of an order operator (e.g., [n] as in XPath).
Here are examples:
The XML file (foo.xml):
<foo a="1" b="2">
Bar <b>hud <i>fiss</i></b> retch<end/>
<tag a="1"/>
</foo>
File-like treatment of XML using XPath-derived path syntax:
Environment-like treatment (i.e., no open/close):
s = xmlGet("foo.xml/foo@a"); // returns "1"
xmlPut("foo.xml/foo/tag[2]", ""); // inserts <tag/> after the
first tag element
xmlPut("foo.xml/foo/tag[2]@a", "2"); // changes above to <tag
$a="2"/>
xmlPut("foo.xml/foo/tag[2]", "text"); // changes above to <tag
$a="2">text</tag>
xmlBase("foo.xml/foo");
xmlPut("tag[2]", "new"); // inserts <tag>new</tag>
after the first tag element
xmlDrop("tag[3]");
File-like treatment (i.e., with open/close):
f = xmlOpen("foo.xml");
s = xmlRead(f, "foo@a");
xmlSeek(f, "foo");
xmlWrite(f, "tag[1]@a", "one");
xmlErase(f, "tag[2]");
xmlClose(f);
Shell example (using the hypothetical XML/XPath filesystem):
cd foo.xml
cat foo@a
mkdir foo/tag[2]
cd foo
echo "2" > tag[2]@a
rm tag[2]
Hypothetical XML-Script example (language that uses xml data structures
natively):
load foo.xml
echo foo@a
foo/tag[2] = ""
base foo
tag[2]@a = 2
drop tag[2]
Received on Wed, 25 Feb 2004 18:45:11 -0700
This archive was generated by hypermail 2.1.8 : Tue Sep 26 2006 - 09:03:11 PDT