Welcome Guest, Not a member yet? Register   Sign In
Reading From XML instead of database?
#2

[eluser]saidbakr[/eluser]
Hello

I found the solution in XML Library inside the CI Wiki. Everything goes well but I need to add <![CDATA[ ]]> to the text content to disallow parsing of HTML tags inside the text here is an example of the xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<posts xmlns:h="http://www.w3.org/TR/html4/">
<item>
<id>0</id>
&lt;title&gt;Title Num 1&lt;/title&gt;
<content>&lt;![CDATA[<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris quis tellus id mauris imperdiet tincidunt. Donec euismod rhoncus urna, ut malesuada sapien vestibulum ut. Ut pretium neque quis velit vehicula elementum rutrum risus dapibus. Vivamus dictum felis ut libero aliquam sit ed non neque auctor velit ultrices vestibulum. Cras tristique consectetur neque non commodo. Praesent ligula justo, pellentesque sit amet venenatis at, dictum sit amet purus. Vivamus ultrices adipiscing erat, a rutrum dolor mattis in.
</p>
<p>
Aenean volutpat pellentesque mauris, sit amet lobortis odio aliquam at. Pellentesque ac ligula id diam cursus dictum. Cras sed justo dui. Vestibulum vitae orci leo. Cras imperdiet tristique adipiscing. Pellentesque orci dolor, consequat sed dictum et, ornare in turpis. Donec sit amet arcu vel lectus coeugiat augue. Donec interdum tincidunt elit vitae venenatis.
</p>
]]>
</content>
<dated>2009-09-10</dated>
<author>Said Bakr</author>
<comments>5</comments>
</item>
<item>
<id>1</id>
&lt;title&gt;Title Num 2&lt;/title&gt;
<content>&lt;![CDATA[
<p>
Morbi ...

However, The generated array from the xml parser is not clean enough it needed some modification to get the data in the view file to be something like &lt;?php echo $item['title'][0] ?&gt; and the index [0] should be found inside the loop, i.e there are no 1,2, 3 etc it only 0.

Thank you all


Messages In This Thread
Reading From XML instead of database? - by El Forum - 09-20-2009, 04:28 PM
Reading From XML instead of database? - by El Forum - 09-20-2009, 07:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB