hackdaddy has asked for the wisdom of the Perl Monks concerning the following question:
I want to "autovivify" keys 'one', 'two', and 'three'. These keys represent XML tags. However, using the tie hash function calls like FETCH and STORE, I really want to create a data structure of hashes with an anonymous array sandwiched between each key. An anonymous hash in the anonymous array will hold the information about the "key". This gets crazy when I want to have tags of the same name as children of the same node, but I want to access them with my "Perl" syntax. (I will also want to maintain the them in the order created.)$x->{one}{two}{three};
Hopefully, you have followed me so far. Now I will get to the point.$x->{one}{two}{three}; $x->{one}{two}{four};
By using the concept of autovivification in tandem with the XPath syntax, I should be able to automatically create an XML tree and populate/access it by using my own user-defined syntax. (Also, it would be cool to have an implicit XML tree -- sort of like the variable $_).use MyClass::XML::XPath; use syntax 'http://www.blah.com/xpath/blah.blah', 'MyClass::XML::XPath +'; /html/head/title[0] = "Page Title"; /html/body/h1[0] = "Some text here"; /html/body/form/input[@type="text" and @name="input"]; /html/body/form/input[@type="submit" and @name="Submit"]; print /*; my $title = /html/head/title[0];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: User-Defined Syntax, XPath, Tied Hashes, and Autovivification
by Abigail-II (Bishop) on Feb 11, 2004 at 11:38 UTC | |
by hackdaddy (Hermit) on Feb 11, 2004 at 12:13 UTC | |
by Anonymous Monk on Feb 11, 2004 at 12:41 UTC | |
|
Re: User-Defined Syntax, XPath, Tied Hashes, and Autovivification
by etcshadow (Priest) on Feb 11, 2004 at 16:40 UTC | |
by Abigail-II (Bishop) on Feb 11, 2004 at 16:53 UTC | |
by etcshadow (Priest) on Feb 11, 2004 at 19:24 UTC |