Do you know where your variables are? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
In my rules, do I refer to this tag as "ns2:Height" or as "Height" somehow accounting for the namespace? You can assign namespace prefixes using the namespaces option, for example namespaces => { 'http://www.example.com/foo' => 'ns2' }, and then use the ns2: prefix in your rules. Or, you can use the same option to map different namespaces to the same prefix, if that is acceptable in your application (!), in the way I showed below (in that case the empty prefix). Can I have rules that just deal with Height, Length, Width, Weight, etc? Yes, you can specify multiple tag names for a rule with |. You can also use regexes to specify rules, as in '/foo/' => ... (although I don't think the two can be combined). Here's an example:
In this code, I've made the _default rule be to die, that way I can make sure during development that I haven't overlooked a tag in the input XML. But you can of course also specify any _default rule you like. By the way, since these questions are going a bit off topic from the original post, it might be best to start a new thread on your questions about XML::Rules, showing your code, enough example input to reproduce, etc. (Short, Self-Contained, Correct Example). In reply to Re^2: hashref with(out) arrays
by haukex
|
|