• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading From XML instead of database?


I need to know how reading a local, or remote, server xml file and using its data instead of database? For example,
<item_title>First title</item_title>
<item_content>First one content blah blah..</item_content>
<item_author>John Loe</item_author>
<item_tite>and so on....

How could I use CI to read this XML file? and what are suitable to do this task, a helper or a plugin? and where could I able to find pre-made such plugins and helpers for CI?


I found the solution in XML Library inside the CI Wiki. Everything goes well but I need to add &lt;![CDATA[ ]]> to the text content to disallow parsing of HTML tags inside the text here is an example of the xml:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<posts xmlns:h="http://www.w3.org/TR/html4/">
&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.
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.
<author>Said Bakr</author>
&lt;title&gt;Title Num 2&lt;/title&gt;
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.