Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Why XML not well formed?

by nan (Novice)
on Jul 06, 2005 at 13:04 UTC ( [id://472882]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^3: Why XML not well formed?
in thread Why XML not well formed?

Hi Don,

Sorry I used $line =~ s/(&)/(& amp;)/g; would it be different with yours?

Many thanks, Nan

Replies are listed 'Best First'.
Re^5: Why XML not well formed?
by BaldPenguin (Friar) on Jul 06, 2005 at 13:32 UTC
    First, the parens in the pattern part of the regex collect the value we find, then the $1 in the replace puts it back in. In that respect the follwing regex would do nothing but spin cycles;
    $line =~ s/(&)/$1/g;
    So, in your regex the first set of parens save the & for later use. But you don't use it, instead you find all of the &s and replace them literaly with "(&)" including the parens.

    That said, the regex I posted would work only if no other entites existed. Take a look at the other regexs above, they do a better job of 'thinking' ahead, to prevent possible errors in the future.

    Somebody could, and I have seen it done, place other entities in the url, such as:
    http://www.test.me/test.pl?me=1&you=1&string=Montréal
    In this case the regex I posted would tranlate to Montréal. Not what you want.

    Don
    WHITEPAGES.COM | INC

    Edit by castaway: Closed small tag in signature

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://472882]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.