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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:36:43+00:00 2026-06-15T12:36:43+00:00

I am using XMLWriter to create xml.Below is my code which is working fine.

  • 0

I am using XMLWriter to create xml.Below is my code which is working fine.

<?php
header("Content-Type: text/xml;");
$writer = new XMLWriter(); 
$writer->openMemory();  
$writer->startDocument('1.0'); 
$writer->setIndent(4); 
$writer->startElement('epp'); 
$writer->startElement("command"); 
$writer->startElement("login"); 
$writer->writeElement('clID', 'hello'); //username
$writer->writeElement('pw', 'abcdefg'); //password
$writer->endElement(); //login
$writer->endElement(); //command
$writer->endElement(); //login
$writer->endDocument(); 
$file =  $writer->outputMemory(true); 
echo $file;

?>

If am using below code I am getting error “Getting Error “Below is a rendering of the page up to the first error.”.

<?php
$time  = time();
echo $time;
header("Content-Type: text/xml;");
$writer = new XMLWriter(); 
$writer->openMemory();  
$writer->startDocument('1.0'); 
$writer->setIndent(4); 
$writer->startElement('epp'); 
$writer->startElement("command"); 
$writer->startElement("login"); 
$writer->writeElement('clID', 'hello'); //username
$writer->writeElement('pw', 'abcdefg'); //password
$writer->endElement(); //login
$writer->endElement(); //command
$writer->endElement(); //login
$writer->endDocument(); 
$file =  $writer->outputMemory(true); 
echo $file;

?>

Error:For above block of code below is the error:I am getting this in google chrome:

 This page contains the following errors:

 error on line 1 at column 1: Document is empty
 Below is a rendering of the page up to the first error.

If I am not using header(“Content-Type: text/xml;”); then above block of code is working but time is displaying and not giving the xml format. Below is the error:

1354510317 hello abcdefg

EDIT:
In Mozilla I am getting below erro:

XML Parsing Error: not well-formed
Location: http://localhost/example.php
Line Number 1, Column 11:1354512268<?xml version="1.0"?>
 ----------^

If I have done anything wrong with my code please suggest.

How “Below is a rendering of the page up to the first error.” error can
be removed?

  • 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-15T12:36:44+00:00Added an answer on June 15, 2026 at 12:36 pm

    If you echo the time outside the XML content, then it’s no longer valid XML which is why the browser is complaining.

    Specifying the content type as text/xml tells the browser to parse the XML and render it in a readable format.

    If you view the source of your failing code, you should see the time followed be the raw XML content.

    The reason it doesn’t look right when you don’t send the text/xml content type is that the browser is essentially seeing the XML tags as HTML and deciding they do nothing to alter the layout so it just shows the plain text values from within the tags.

    If you want to mix normal output with XML output in your page, you would need to format the XML nicely and HTML encode it.

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

Sidebar

Related Questions

I'm using XMLWriter http://www.php.net/manual/en/book.xmlwriter.php to let my webclient create an XML File. In the
I am using XmlWriter.Create() to get a writer instance then write the XML, but
I was trying to create an xml which contains a large data using XMLWriter,
I'm using XML Writer to create a log of some important events in my
I'm using xmlwriter to create an xml document. The xml document looks like this:
Below is my code to transform XML using XSLT: Private Sub Transform(ByVal XslUri As
I am using XMLwriter to create HTML which works well, but now I need
Am creating an xml file using xmlwriter,i thought it works fine but when i
I am trying to create an XML document with multiple namespaces using System.Xml.Xmlwriter in
I am trying to create an XML file using string data. (Which is itself

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.