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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:26:34+00:00 2026-06-04T04:26:34+00:00

i have an xml file (scores.xml) which im using a php codes to add

  • 0

i have an xml file (scores.xml) which im using a php codes to add new Tags to it.

i have a tag called Header which contain some html code

<![CDATA[<tr><td colspan='7' id='headertd'>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img border='0' src='images/euro.png' />
&nbsp;&nbsp;&nbsp;&nbsp;
UEFA Euro 2012 Qualifications</td></tr>]]>

when im writing this code in the form of the pgp script and submiting everything goes normal to the XML file except the header tag…. im getting an error in the php script and the code is going in the xml tag like that:

&lt;![CDATA[&lt;tr&gt;&lt;td colspan='7' id='headertd'&gt;&#13;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#13;
&lt;img border='0' src='images/euro.png' /&gt;&#13;
&nbsp;&nbsp;&nbsp;&nbsp;&#13;
UEFA Euro 2012 Qualifications&lt;/td&gt;&lt;/tr&gt;]]&gt;

so thats getting wrong info to my xml…
is there anyway i can fix this ? and avoid the transformation of these codes?

thats my php code :

<?php
if (isset($_POST['submitted'])) {//If the user submitted the form, then add to the XML file
    //Load the scores XML file
    $scores = new DOMDocument();
    $scores -> load('../scores.xml');

    //Get the <Games> tag
    $games = $scores -> getElementsByTagName('Games');

    //Create the new <Game> tag 

    $newGame = $scores -> createElement("Game");
    $newGame -> appendChild($scores -> createElement("Header", $_POST['header']));

    //Add the new <Game> tag under the <Games> tag
    $games -> item(0) -> appendChild($newGame);

    //Save again
    $scores -> save('../scores.xml');

    echo "New game added.";
}
?>

<form id="form1" method="post" action="">
Header: <textarea style=" color:#000;" name="header" cols="73" rows="6" > </textarea>
<br><input type="submit" name="submitted" name="Add new row">
</form>

i have no user interface im just using this script to make work easier for me to post stuff on my website!

your help is much appreciated!

Thanks in Advance!

  • 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-04T04:26:35+00:00Added an answer on June 4, 2026 at 4:26 am

    [edit 2]
    Hmmmm, sorry for the wrong answer, i was thinking about it, but it’s very normal that the PHP script converted it to an “encoded” form, because when you add html tags, then the xml structure will be ruined so it must be encoded. Therefore, later when you try to retrieve the data, you have to decode it with html_entity_decode() to export it properly to the browser.

    [edit1]
    As i see, the content is “encoded”, so before saving the data decode it with html_entity_decode().
    And here the “final” code:

    <?php
    if (isset($_POST['submitted'])) {//If the user submitted the form, then add to the XML file
        //Load the scores XML file
        $scores = new DOMDocument();
        $scores -> load('../scores.xml');
    
        //Get the <Games> tag
        $games = $scores -> getElementsByTagName('Games');
    
        //Create the new <Game> tag 
    
        $newGame = $scores -> createElement("Game");
        $newGame -> appendChild($scores -> createElement("Header", html_entity_decode($_POST['header'])));
    
        //Add the new <Game> tag under the <Games> tag
        $games -> item(0) -> appendChild($newGame);
    
        //Save again
        $scores -> save('../scores.xml');
    
        echo "New game added.";
    }
    ?>
    
    <form id="form1" method="post" action="">
    Header: <textarea style=" color:#000;" name="header" cols="73" rows="6" > </textarea>
    <br><input type="submit" name="submitted" name="Add new row">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file which I need to parse using PHP and send
I have a collection of about 8,000 test scores in an XML file. Using
Okay, I have a function which reads a xml file and creates controls using
I have parsed XML file into objects, in which each object has a 1:1
i have an xml file sitemap.xml as shown below ..i need to add one
I have a process that parses an XML file using JDOM and xpath to
I have an XML file which contains lists of stores, a simplified version is
I have a directory, d:/resources/xxxxx/file-name.xxx that stores the file types: .png, .xml, .pdf, which
I have this XML file from which I'm grabbing all the data: <?xml version=1.0
I have to read/write an XML file that stores its data as bit masked

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.