http://www.perlmonks.org?node_id=982806


in reply to Re: How can I use XML::Simple parser to read and parse greater then (>), less then (<) and ampersand (&) symbol..
in thread How can I use XML::Simple parser to read and parse greater then (>), less then (<) and ampersand (&) symbol..

hi thank you for your quick reply. well there is no quote present over these symbel. since i have to put validation check for these symbol only. here i am giving sample for my input file.
<query> insert into name (name, age, address) (select from age_tab where age > + 19 ) </query>
  • Comment on Re^2: How can I use XML::Simple parser to read and parse greater then (>), less then (<) and ampersand (&) symbol..
  • Download Code

Replies are listed 'Best First'.
Re^3: How can I use XML::Simple parser to read and parse greater then (>), less then (<) and ampersand (&) symbol..
by Jenda (Abbot) on Jul 20, 2012 at 17:01 UTC

    You might be able to run the file through some filter that'll try to guess which <, > or & belongs to a tag/entity and which one does not, but there's no guarantee it'll guess correctly every time. Fix or get fixed whatever produces this invalid format.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Re^3: How can I use XML::Simple parser to read and parse greater then (>), less then (<) and ampersand (&) symbol..
by amias (Novice) on Dec 12, 2012 at 11:36 UTC

    You should enclose them in a CDATA block to keep them safe from the parser , all parsers should respect this.

     <tag><![CDATA <?>&;]!> ]]></tag>

    the only thing you cannot put in CDATA is ]]> as its the CDATA terminator , however if its essential then you could do something like

    <tag><![CDATA ]]]]><![CDATA >]]></tag>

    for the full info see http://www.w3schools.com/xml/xml_cdata.asp