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 7811251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:05:30+00:00 2026-06-02T04:05:30+00:00

I have a slight problem. I need to parse a file and populate a

  • 0

I have a slight problem. I need to parse a file and populate a web banner with the results. Problem is, the file is called : “_banner_products.php” and it’s contents are as follows:

<?php header('Content-Type:text/xml'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<carouselle>
 <firstLayer>
   <layerName>Leica Disto X310</layerName>
   <layerProduct>Disto X310</layerProduct>
   <layerPic>http://www.leicaestonia.ee/extensions/boxes_design/flashpics/1334482548.jpg</layerPic>
   <layerPrice>0,-</layerPrice>
   <layerPriceOld></layerPriceOld>
   <layerLink>http://www.leicaestonia.ee/index.php?id=11627</layerLink>
   <layerTimer>01.05.2012 00:00</layerTimer>
 </firstLayer>
 <firstLayer>
   .....
   .....
</firstLayer>
</carouselle>

How can I loop through this file to group all the “firstLayer” children into one and so on..
If I just use:

$file = fopen("_banner_products.php", "r");
while (!feof($file)){
    $line = fgets($file);
}

simplexml_load_file throws this-
“_banner_products.php:1: parser error : Start tag expected, ‘<‘ “

Then I only get the contents of the <…> tags meaning there is no way for me to differentiate if I am out of the scope already.

Thanks for anyone responding. If anything is unclear I´ll try to explain more.

EDIT.
Thank you for the solution, indeed using the full URL worked:

simplexml_load_file("http://localhost/MySite/_banner_products.php");
  • 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-06-02T04:05:32+00:00Added an answer on June 2, 2026 at 4:05 am

    You are having issue because simplexml_load_file is treating your file like a local xml file .. what you need to do is add the full URL

    Example

     simplexml_load_file("http://localhost/web/_banner_products.php"); 
    

    Use Case getting layerName for example

    _banner_products.php

    <?php
    header ( 'Content-Type:text/xml' );
    echo '<?xml version="1.0" encoding="UTF-8"?>';
    ?>
    <carouselle>
     <firstLayer>
       <layerName>Leica Disto X310</layerName>
       <layerProduct>Disto X310</layerProduct>
       <layerPic>http://www.leicaestonia.ee/extensions/boxes_design/flashpics/1334482548.jpg</layerPic>
       <layerPrice>0,-</layerPrice>
       <layerPriceOld></layerPriceOld>
       <layerLink>http://www.leicaestonia.ee/index.php?id=11627</layerLink>
       <layerTimer>01.05.2012 00:00</layerTimer>
     </firstLayer>
     <firstLayer>
       <layerName>Leica Disto X310</layerName>
       <layerProduct>Disto X310</layerProduct>
       <layerPic>http://www.leicaestonia.ee/extensions/boxes_design/flashpics/1334482548.jpg</layerPic>
       <layerPrice>0,-</layerPrice>
       <layerPriceOld></layerPriceOld>
       <layerLink>http://www.leicaestonia.ee/index.php?id=11627</layerLink>
       <layerTimer>01.05.2012 00:00</layerTimer>
     </firstLayer>
    </carouselle>
    

    view details

    $xml = simplexml_load_file("http://localhost/lab/stockoverflow/_banner_products.php");
    
    echo "<pre>" ;
    foreach($xml as $key => $element)
    {
        echo $element->layerName , PHP_EOL ;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new at PHP and came across a slight problem. I have a
I have run in to a slight problem. The story goes as follows: I
I have a slight problem... I need to connect the Windows Phone 6 emulator
I have a slight problem where my << operator is not being called correctly.
I have a slight problem. I have several arrays in php with different team
people. I have slight problem with GD2 text on image. I have everything working
I have a slight problem with a path: D:\\Music\\DJ Ti%C3%ABsto\\Tiesto\\Adagio For Strings (Spirit of
I have a slight problem... we made a change to our url structure the
I have a slight problem, I am trying to capture the input of two
am new here. i have a slight problem; PLease look at the following code

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.