How to break CDATA using php functions,
e.g.
<![CDATA[
<script src="http://myfile.js"> <br />
<b>yes your file</b><br />
]]>
How would I echo the script src. i.e.
http://myfile.js
See
readfile(), but I'm not sure why you would want to do that. What are you actually trying to accomplish?
Okay, I want to get this url from a XML file, and this url changes every time we refresh our page, I tried explode(), but that didnt work,
(2011-10-04, 09:35 PM)Malcolm. Wrote: [ -> ]Use SimpleXML to get the value.
I've tried it also, simplexml , only thing I can able to get is, parent and its sub nodes, but this CDATA is in a node and I want to only take the url from it, It can be done in this way,
$storeVal=$openfileusingsimpleXML -> root -> node;
Now this $storeVal has the whole CDATA. Now is there a way to convert $storeVal it into parts, or to get a specific thing (url) from this variable?
simplest way is to
$storeValparts = =explode('"', $storeVal);
$url = $storeValparts[1];
as long as the code you are parsing is exactly like you have above and there is never any double quotes before url you are trying to grab.