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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:26:23+00:00 2026-05-13T15:26:23+00:00

I have the following two errors when using XMLReader. 1) Warning: XMLReader::read() [xmlreader.read]: MyXML.xml:43102:

  • 0

I have the following two errors when using XMLReader.

1) Warning: XMLReader::read() [xmlreader.read]: MyXML.xml:43102: parser error : xmlParseEntityRef: no name

2) Warning: XMLReader::read() [xmlreader.read]: ^ in MyXMLReader.php on line 56

Does anyone know what those refer to?

My PHP Code (The XML file is about 100MB so I can’t include it):

<?php 

//Assign file names
$XMLFile = 'MyXML.xml';
$CSVFile = 'MyCSV.csv';

//take start time to calculate run-time
$time_start = time();

//Open PHP's XMLReader.  XMLReader opens each element in the XML one by one to keep memory use small.
$xml = new XMLReader(); 
$xml->open($XMLFile, null, 1<<19); 

//Loop through all elements.  Save all text from tags and attributes.
while ($xml->read()) {

    if($xml->nodeType == XMLReader::TEXT) { 
        $row[$xml->name] = $xml->value;
    }

    if($xml->hasAttributes)  {
        while($xml->moveToNextAttribute()) { 
            $row[$xml->name] = $xml->value;
        }
    }
}

//save the titles which should appear in CSV file.  All others will not be included.
$SavedRows = $row;
unset($row);

//Remove unnecessary columns i.e. datasource URLs
$RemoveColumn='xmlns:message, xmlns:common, xmlns:frb, xmlns:xsi, xsi:schemaLocation, xmlns:kf';
$RemoveColumns = explode(',', $RemoveColumn);

foreach($RemoveColumns as $key => $val) {
    $val = trim($val);
    unset($SavedRows[$val]);
}

//initiate all rows which should be included
foreach($SavedRows as $key => $val) {
    $row[$key] = '';
}

//Create csv file
$fp = fopen($CSVFile, 'w');

//Input the column headings as first row
fputcsv($fp, array_keys($row), ',');

// Start 2nd loop through XML.
$xml = new XMLReader(); 
$xml->open($XMLFile, null, 1<<19); 

while ($xml->read()) {

    //Determine if tag is empty (An empty tag will contain data) Non empty tags contain series information.
    $Output = $xml->isEmptyElement;

    //Take data from non empty XML tags
    if($xml->nodeType == XMLReader::TEXT) { 
        if(isset($SavedRows[$xml->name])) {
            $row[$xml->name] = $xml->value;
        }
    }

    //take data from XML tag attributes
    if($xml->hasAttributes)  {
        while($xml->moveToNextAttribute()) { 
            if(isset($SavedRows[$xml->name])) {
                $row[$xml->name] = $xml->value;
            }
        }
    }

    //If tag is empty, assume it is data and write row to file.
    if($Output) {
        fputcsv($fp, array_values($row), ',');
    }

}

//Close file handle
fclose($fp);

//Calculate runtime
$time_end = time();
$time = $time_end - $time_start;

 echo "Complete.  Runtime: $time seconds";

 ?>
  • 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-13T15:26:24+00:00Added an answer on May 13, 2026 at 3:26 pm
    xmlParseEntityRef: no name 
    

    Means you’ve got bogus unescaped ampersands in the XML file. (Well, “XML”… technically if it ain’t well-formed, it ain’t XML.)

    You’ll need to check the file for lone &s (or fix the code that generated it) to escape them to &amp;. According to the error, the first one’s on line 43102 of the file (yikes!).

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

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.