Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first thing I see that will fail is:</p> <pre><code>width="100%" will not match /width=\"[0-9]*\"/ </code></pre> <p>I don't know the exact PHP definition of regular expression; But I am not sure this will match (A space in the reg-expression may match zero or more spaces in the target text but the other way around will not work):</p> <pre><code>&gt; &lt;param will not match (probably) /&gt;&lt;param/ </code></pre> <p>As you can see parsing XML with regular expressions is hard and error prone.<br> What you really want to do is use an XML SAX parser.</p> <p>Try this: PS my PHP is not great so it could contain mistakes. </p> <p>PS. The long URLs were not encoded correctly for XML. I used urlencode() here just to stop the error messages. I did not check to see if that made sense.</p> <pre><code>&lt;?php $test = '&lt;object height="81" width="100%"&gt;' .'&lt;param name="movie" value="' .urlencode('http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Ftheshiverman%2Fsummer-beats-july-2010&amp;secret_url=false') .'"&gt;' .'&lt;/param&gt;' .'&lt;param name="allowscriptaccess" value="always"&gt;' .'&lt;/param&gt;' .'&lt;embed allowscriptaccess="always" height="81" src="' .urlencode('http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Ftheshiverman%2Fsummer-beats-july-2010&amp;secret_url=false') .'" type="application/x-shockwave-flash" width="100%"&gt;' .'&lt;/embed&gt;' .'&lt;/object&gt;'; function JustPrint($parser,$data) { print $data; } function OpenTag($parser,$name ,$attribs) { // For special tags add a new attribute. if (strcasecmp($name, "object") == 0) { $attribs['Martin'] = 'York'; } // Print the tag. print "&lt;$name "; foreach ($attribs as $loop =&gt; $value) { print "$loop=\"$value\" "; } print "&gt;\n"; } function CloseTag($parser,$name) { print "&lt;$name/&gt;\n"; } $xmlParser = xml_parser_create(); xml_set_default_handler($xmlParser ,'JustPrint' ); xml_set_element_handler($xmlParser, 'OpenTag' , 'CloseTag' ); xml_parse($xmlParser, $test); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload