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

  • Home
  • SEARCH
  • 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 7769379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:08:43+00:00 2026-06-01T16:08:43+00:00

I have a javascript image gallery which is getting data from an XML file.

  • 0

I have a javascript image gallery which is getting data from an XML file. Im in the process of building a backend function in order for someone else to easy update the gallery. All the data required in the XML file, is available to me from a table in my database.

<?xml version="1.0" encoding="UTF-8"?>
<portfolio>
<items> 
    <item>
        <thumbnail>images/banner001.jpg</thumbnail>
        <preview>images/preview.jpg</preview>
        <category>banner</category>
        <description>Swatch MTV </description>
    </item>
    <item>
        <thumbnail>images/banner002.jpg</thumbnail>
        <preview>images/preview.jpg</preview>
        <category>banner,campaign</category>
        <description>Nike iD</description>
    </item>
    <item>
        <thumbnail>images/banner003.jpg</thumbnail>
        <preview>images/preview.jpg</preview>
        <category>banner</category>
        <description>Sony Handycam</description>
    </item>
    <item>
        <thumbnail>images/banner006.jpg</thumbnail>
        <preview>images/preview.jpg</preview>
        <category>banner</category>
        <description>Statoil App kampagne</description>
    </item>     
    <item>
        <thumbnail>images/design006.jpg</thumbnail>
        <preview>images/preview.jpg</preview>
        <category>web</category>
        <description>Hempel Website design</description>
    </item>

</items>
</portfolio>

In this regard I have a couple of questions (please keep in mind that im fairly new to php):

  1. which is the better/easier option: update the existing xml file or simply overwrite the entire xml file with newer/updated data?
  2. how do I create the same xml format using php?
  3. I have been looking at both SimpleXML and the DOMDocument. Which one is better/easier to use in my case?

I would be grateful for any help you guys can give me. If posting code, please include a short description/explanation.

Please let me know if you need anything clarified.

  • 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-01T16:08:44+00:00Added an answer on June 1, 2026 at 4:08 pm

    I think it is easy when you overwrite the entire xml file with newer/updated data. Below is the php file which creates the xml data by connecting to the database.

    test.php

    <?php header('Content-type: application/xml');echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    
        //connect to db here
        $query1 = "select datas";
        $res1   = mysql_query($query1);
        echo '<portfolio>';
        echo '<items>';
        while($row1 = mysql_fetch_array($res1)) 
        {
        ?>
          <item>
            <thumbnail><?php echo $row1['yourdata1']; ?></thumbnail>
            <preview><?php echo $row1['yourdata2']; ?></preview>
            <category><?php echo $row1['yourdata3']; ?></category>
            <description><?php echo $row1['yourdata4']; ?></description>
          </item>
       <?php
       } 
      ?>
      </items>
    </portfolio>
    

    If the above filename is test.php, then you can write .htaccess redirection to redirect the url to .php file when the url is given as .xml

    Below code redirects to test.php when the url is given as http://yoursitename.com/test.xml

    RewriteCond %{REQUEST_URI} test.xml
    RewriteRule test.xml test.php [L] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an image gallery which pulls in random images from the folder images/flip_images/.
I have a javascript function that will show the image you're about to upload
I have the following JavaScript to get a random image from a list of
I have web application of which major part is javascript. I request images from
I have a lite-javascript run image gallery. The javascript grabs each <img> element in
I am trying to transform a bit of xml which represents an image gallery
I have this source data [gallery] Title [galleryitem]http://www.google.com/image.jpg[/galleryitem] [galleryitem]http://www.google.com/image.jpg[/galleryitem] [galleryitem]http://www.google.com/image.jpg[/galleryitem] [galleryitem]http://www.google.com/image.jpg[/galleryitem] [galleryitem]http://www.google.com/image.jpg[/galleryitem] [galleryitem]http://www.google.com/image.jpg[/galleryitem] [/gallery]
I have problem with dynamically created image (JavaScript). I want to change the innerHTML
I have a Javascript Map kit, and it use Image object to load images.
I have a script that uploads an image using JavaScript, as seen here .

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.