Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3433408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:34:12+00:00 2026-05-18T07:34:12+00:00

I am having troubles reading XML, I followed this tutorial , and generated the

  • 0

I am having troubles reading XML, I followed this tutorial, and generated the code below.

When I open my controller I get

Parse error: parse error, expecting T_STRING' orT_VARIABLE’ or `T_NUM_STRING’ in C:\wamp\www\ci_doctrine\system\application\controllers\welcome.php on line 49

line 49 is foreach($xmlData[‘item’] as $row) I dont know what to do any idea, suggestions? help really appreciated

This is my code:

<?php

class Welcome extends Controller {

/*function Welcome()
{
    parent::Controller();   
}

*/

function index()
{


    //$this->load->view('welcome_message');


    //load the parser library
    $this->load->library('parser');

           $data['title'] = 'Parsing XML using Simplexml class of CodeIgniter';

           $data['products'] = $this->_getXML('myxml');

       $this->parser->parse('table_view', $data);

    //$this->load->library('parser');
        //$data['title'] = 'Parsing XML using SimpleXML class of CodeIgniter';

}

function _getXML($fname)
{

            $filename = $fname.'.xml';
            $xmlfile="“C:\wamp\www\" . $filename;
            $xmlRaw = file_get_contents($xmlfile);

            $this->load->library('simplexml');
            $xmlData = $this->simplexml->xml_parse($xmlRaw);

            foreach($xmlData['item'] as $row)
            {

        $result .= '<tr>';
        $result .= '<td>'.$row['id'].'</td>';
        $result .= '<td>'.$row['name'].'</td>';
        $result .= '<td>'.$row['category'].'</td>';
        $result .= '<td>$ '.$row['price'].'</td>';
        $result .= '</tr>';

            }
             return $result;
    }

} 
//End of file welcome.php 
// Location: ./system/application/controllers/welcome.php 

?>

<item>
    <id>1</id>
    <name>iPhone</name>
    <category>Mobile</category>
    <price>300</price>
</item>

<item>
    <id>2</id>
    <name>iMac</name>
    <category>Desktop Computers</category>
    <price>2500</price>
</item>

<item>
    <id>3</id>
    <name>MacBook Pro</name>
    <category>Mobile PC</category>
    <price>2000</price>
</item>

<item>
    <id>4</id>
    <name>iTouch</name>
    <category>Gadgets</category>
    <price>150</price>
</item>

<item>
    <id>5</id>
    <name>Wii</name>
    <category>Gaming</category>
    <price>1250</price>
</item>

<item>
    <id>6</id>
    <name>Time Capsule</name>
    <category>Acessories</category>
    <price>1000</price>
</item>

<item>
    <id>7</id>
    <name>Apple TV</name>
    <category>Gadgets</category>
    <price>800</price>
</item>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:34:13+00:00Added an answer on May 18, 2026 at 7:34 am

    You’ve got a double quote on $xmlfile="“C:\wamp\www\"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having troubles reading from this api http://api.xhanch.com/islamic-get-prayer-time.php?lng=67&lat=24&yy=2012&mm=7&gmt=5&m=json Here's my code: new Read().execute(sunrise); public
I'm having troubles reading a Json result back from a controller method... I have
I'm having troubles reading values from an xml file. Here is the xml file:
I'm having some troubles while reading from an exel in c#. I have this
I'm having trouble reading this xml with jQuery. http://jsfiddle.net/VLtqY/2/ XML: <myElements type=AA coID=A923> <element1>01</element1>
Firs of all thanks for reading this. I'm having trouble updating the progress from
I'm having troubles getting this to work. Basically I have a python program that
I seem to be having trouble reading preferences from my AppWidgetProvider class. My code
I'm having some troubles with using the std::sort algorithm here. I was reading that
Ok, here is my current code. I'm having trouble reading in the file and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.