Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: XML:Simple read tag value with regex

by kcott (Chancellor)
on May 07, 2013 at 13:34 UTC ( #1032480=note: print w/replies, xml ) Need Help??


in reply to XML:Simple read tag value with regex

G'day filipebean,

There's a number of special characters that may need to be escaped in XML content: "<" to "&lt;"; ">" to "&gt;"; and "&" to "&amp;" (see XML Predefined Entities). So,

<rule>['^(<xyz>)']</rule>

would become

<rule>['^(&lt;xyz&gt;)']</rule>

Given the readability issues, it might be better to use CDATA blocks (see XML CDATA Sections) to escape the entire regex, e.g.

<rule><![CDATA[['^(<xyz>)']]]></rule>

[Note: I haven't investigated how XML::Simple interacts with these constructs.]

-- Ken

Replies are listed 'Best First'.
Re^2: XML:Simple read tag value with regex
by filipebean (Novice) on May 07, 2013 at 15:06 UTC

    Hi all,

    thank for your answers. I tried the CDATA as you suggest and it works perfectly :)

    best regards.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032480]
help
Chatterbox?
[karlgoethebier]: good morning
[Corion]: Hi karlgoethebier!
[karlgoethebier]: anybody ever noticed the double bracket operator: while (<<>>) {print;}?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-07-21 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (319 votes). Check out past polls.