rvdokkum Posted May 31, 2011 Share Posted May 31, 2011 i like to use the str_replace to change the header of xml dataoriginal xml data:<?xml version="1.0" encoding="UTF-8"?><tumblr version="1.0"><tumblelog .........i like to replace :<?xml version="1.0" encoding="UTF-8"?>with<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="xsl_template_document"?>how do i handle the special characters in these strings?i try to implement this example. therefore i need to change the header of my xml data to point to my stylesheet xsl file.http://modxcms.com/forums/index.php/topic,....html#msg127144 Link to comment Share on other sites More sharing options...
[dx] Posted May 31, 2011 Share Posted May 31, 2011 When using function, try with str_replace('something', 'something "else"', $string);So use single quotes for arguments.If it won't work use then version=\"1.0\" etc. Link to comment Share on other sites More sharing options...
rvdokkum Posted May 31, 2011 Author Share Posted May 31, 2011 When using function, try with str_replace('something', 'something "else"', $string);So use single quotes for arguments.If it won't work use then version=\"1.0\" etc.give it a trystill can't get it to work Link to comment Share on other sites More sharing options...
Ingolme Posted May 31, 2011 Share Posted May 31, 2011 You can either replace the tags with string functions, or you can use PHP's DOMDocument class.Replacing the strings is easy: $result = str_ireplace('<?xml version="1.0" encoding="UTF-8"?>','<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="xsl_template_document"?>',$xmlString); The only problem with it is that if you have extra spaces it won't be detected.If you use PHP's DOMDocument class you can use createProcessingInstruction() and insertBefore() to add the stylesheet. Link to comment Share on other sites More sharing options...
rvdokkum Posted June 6, 2011 Author Share Posted June 6, 2011 no longer need to change te header of the xml.after switching to server side parsing of the xslt. using php. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.