By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

Reading Comment Lines from XML File using PHP

P: 1
Hi,does anyone have idea how to read comment lines from xml using php?
Ex :
<text>
<p> <!--paragraph1--> some text </p>
<p> <!--paragraph2--> again some text</p>
</text>

output :
some text
again some text

but i need to store even paragraph1 & 2 in some variable.



Appreciate a quick reply
Nov 17 '11 #1
Share this Question
Share on Google+
1 Reply


zorgi
Expert 100+
P: 431
Wrap your HTML into CDATA tags:

Expand|Select|Wrap|Line Numbers
  1. <text>
  2. <![CDATA[
  3.     <p> <!--paragraph1--> some text </p>
  4.     <p><!--paragraph2--> again some text</p>
  5. ]]>
  6. </text>
  7.  
and in your php code:

Expand|Select|Wrap|Line Numbers
  1. $xml = simplexml_load_file('path/to/your/file.xml', 'SimpleXMLElement', LIBXML_NOCDATA);
  2. echo $xml -> text;
  3.  
Nov 17 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.