Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^15: aXML vs TT2

by ikegami (Patriarch)
on Oct 23, 2011 at 04:00 UTC ( [id://933131]=note: print w/replies, xml ) Need Help??


in reply to Re^14: aXML vs TT2
in thread aXML vs TT2

"Rock & Roll" is "Rock & Roll" roll in XML, so it would need to be "Rock &amp Roll" in aXML that outputs XML, the primary intended use of aXML.

Replies are listed 'Best First'.
Re^16: aXML vs TT2
by Logicus (Initiate) on Oct 23, 2011 at 04:22 UTC

    No it wouldn't. Your clutching at straws now.

    Lets say you want to output the following XML file;

    <artists> <artist> <name>Aerosmith</name> <genre>Rock &amp; Roll</genre> </artist> <artist> <name>Abba</name> <genre>Pop</genre> </artist> </artists>

    And you want to generate that using aXML. The code would be :

    <artists> <db_select> <query> SELECT * FROM artists</query> <mask> <artist> <name><d>name</d></name> <genre><d>genre</d></genre> </artist> </mask> </db_select> </artists>

    Now if the & in the data has been encoded to &amp; prior to being stored in the database then when you pull it out it's ready to go, if on the other hand it's stored in the database as the single char &, then your going to want to convert it (and any other examples in the data) before output.

    You can do that by simply creating a plugin called something like <convert_amps>. The code of which will look like:

    $plugins->{'convert_amps'} = sub { my $data = $_[1]; $data =~ s@\&@\&amp;@gs; return $data; };

    Now you just wrap the above aXML code with the new tag.

    <convert_amps> <artists> <db_select> <query> SELECT * FROM artists</query> <mask> <artist> <name><d>name</d></name> <genre><d>genre</d></genre> </artist> </mask> </db_select> </artists> </convert_amps>

    Now obviously if the & is encoded in the database your going to end up with &amp;amp;, but then you could just code the plugin to be a bit smarter than the above example, or you could make sure your data is clean to begin with.

    Your actually already using something similar to aXML on this very site when you wrap your code in <code> tags!

      So your solution to output static text "Rock &amp; Roll" is to take it out of the template and put it in a database?

        No. Where did you get that idea from?

        If you create an aXML file and enter into it the following, exactly as it appears here:

        Rock &amp; Roll

        You will see in your browser displayed :

        Rock & Roll

        It really is as simple as that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://933131]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-25 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found