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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:51:15+00:00 2026-06-15T02:51:15+00:00

I’m trying to restructure some XML by taking the data, creating a DOM doc,

  • 0

I’m trying to restructure some XML by taking the data, creating a DOM doc, and transferring across just the bits I need, before saving the output, however I keep getting a “XML Parsing Error: no element found: Line Number 1, Column 1:” error. I think it’s related to the blank tags inside the first :

<?xml version="1.0" encoding="UTF-8"?>
<report title="My Programs" name="aAffiliateMyProgramsReport" time="2012-11-27 16:06">
<matrix rowcount="2">
<rows>
 <row>
  <>You must select one or more sale events before editing</>
 </row>
</rows>
</matrix>
<matrix rowcount="2343">
    <rows>
        <row>
            <siteName>thewebsite.com</siteName>
            <affiliateId>123456</affiliateId>
            <programName>TheProgram.com</programName>
            <currentStatusExcel>Ok</currentStatusExcel>
            <programId>203866</programId>
            <applicationDate>2012-09-15</applicationDate>
            <programTariffAmount>0.0</programTariffAmount>
            <programTariffCurrency>GBP</programTariffCurrency>
            <programTariffPercentage>0.0</programTariffPercentage>
            <status>Accepted</status>
            <event>Unique visitor</event>
            <eventIdView>2</eventIdView>
            <eventLastModified>2011-03-15</eventLastModified>
            <segmentID>1</segmentID>
            <segmentName>General</segmentName>
            <lastModified>2012-09-15</lastModified>
        </row>........

And here’s the PHP I’m trying to run:

//contents of MyPrograms report - tested $query in browser many times: it is correct
$query = $q1.$siteID.$q2.$rKey.$q3;

//create DOM document for newTree
$newTree = new DOMDocument();
$newTree->formatOutput =true;
$r = $newTree->createElement ("ProgramTariffs");
$newTree->appendChild($r);

//load contents of MyPrograms report into an xml element
//$oldTree = simplexml_load_file($query);
//that wasn't working so tried file_get_contents instead
$oldTree = file_get_contents($query);

//the above is now at least allowing this script to produce an xml file, but it just contains 
"<?xml version="1.0"?> <ProgramTariffs/>" 
//and still throws the no element found error.................................

//for each instance of a program id in $oldTree.....
foreach($oldTree->matrix->rows->row as $program)
    { //an attempt to skip over first $program if nothing is set
    if (!empty($program->programId)) {

//create the top line container tag
        $row = $newTree->createElement ("programTariff");

//create the container tag for programId
        $progID = $newTree->createElement("programId");
        //fill it with the information you want
        $progID->appendChild ( $newTree->createTextNode ( $program->programId ) );
        //attach this information to the row
        $row->appendChild($progID);

//create the container tag for eventName
        $eventName = $newTree->createElement("eventName");
        //fill it with the information you want
        $eventName->appendChild ( $newTree->createTextNode ( $program->event ) );
        //attach this information to the row
        $row->appendChild($eventName);

//create the container tag for eventAmount
        $eventPercent = $newTree->createElement("eventPercent");
        //fill it with the information you want
        $eventPercent->appendChild ( $newTree->createTextNode ( $program->programTariffPercentage ) );
    //attach this information to the row
        $row->appendChild($eventPercent);

  //attach all of the above to a row in NewTree
    $r->appendChild ($row);
     }
}
//save the output
$newTree->save("ProgramTariffs.xml");

Have I made a basic mistake in accessing the original XML, or do I need to find a better way to work around the row containing a tag name of “<>” ?

I await your wrath / salvation

  • 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-15T02:51:16+00:00Added an answer on June 15, 2026 at 2:51 am

    You can always do this to strip the blank tags from the document:

    $oldTree = file_get_contents($query);
    $oldTree = str_replace(array('<>', '</>'), '', $oldTree);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.