473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Reading Comment Lines from XML File using PHP

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
1 1653
zorgi
431 Expert 256MB
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

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

Similar topics

1
by: Igor Zelfon | last post by:
I have the following code in an asp that just seems to hang when executed. When I disable the "Set theFileReader = fileObj.OpenTextFile(contentFile,1,True)" line, I see that the file exists. I am...
6
by: Gerald Maher | last post by:
Hi Reading in XML file using C#, changing elements and saving back to the file, how can i do that ? I want to be able to read an XML file and read out Elements. for example <name>Tom</tom> ...
3
by: CD | last post by:
Hi, I am getting a problem using the following piece of code: Dim strfile As Object Set strfile = FSO.OpenTextFile(stFilePath, 1) Do While Not strfile.AtEndOfStream strtext =...
5
by: Z.K. | last post by:
In C#, using the StreamReader, how do I detect when you get to the end of line. I am reading a text file using the Read() function and I need to detect the \n\r, but everything I try does not...
4
by: manickkarthik | last post by:
Hi, I want to know, How we will read the XML File Comments using PHP Code. Thaks in advance.
5
by: prasun | last post by:
hi guys... can anyone of u ans me how to read a microsoft excel file using c..... if possibel give the lines of code..
5
by: sajithamol | last post by:
I'm trying to read a properties file using BufferedInputStream and getResourceAsStream(),but getting "java.io.IOException: Stream closed' exception. My properties file is not set in the classpath,...
6
by: Stephen | last post by:
I am reading a text file using TextReader reader = new StreamReader("file.txt"); like I have done many a times before. I then execute the statement string a = reader.ReadToEnd(); this string is...
4
by: newGuy001 | last post by:
Hi Guys, I am new to this forum and I am totally impressed with all of the knowledge. I am need of some help because I have almost pulled all of my hair out. I am trying to create a very simple...
4
gpraghuram
by: gpraghuram | last post by:
Hi all, I am in the process of writing a small perl code which can read a PDF file. I want to know which perl library should i use for this. Like PDF::API2 or which one.... Thanks Raghuram
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.