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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:33:36+00:00 2026-05-19T02:33:36+00:00

I tried created an XML file using below code. $xml = new SimpleXMLElement(‘<xml />’);

  • 0

I tried created an XML file using below code.

$xml = new SimpleXMLElement('<xml />');
while($rs = db_fetch_object($d_res)){
 $cmp = $xml->addChild('Company');
 $cmp->addChild('ID', $rs->nid);
 $cmp->addChild('Name', trim($rs->title));
 $cmp->addChild('Created', $rs->created);
 $cmp->addChild('Updated', $rs->changed);
}
header("Content-type: text/xml;charset=utf-8;");
print($xml->asXML());

But when I try to validate it I am getting below warnings

  1. No DOCTYPE found! Checking XML syntax only.
  2. No Character encoding declared at document level.

How to clear them? The XML is here and the validator used is validator.w3.org.

  • 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-19T02:33:36+00:00Added an answer on May 19, 2026 at 2:33 am

    Although these are warnings that you could possibly ignore, it is indeed a good idea to try to fix them.

    The first message indicates that the xml file doesn’t specify any DTD; the second one refers to the fact that the xml directive doesn’t contain any encoding attribute.

    Unfortunately, from looking at the simplexml API, it doesn’t look like it is possible to add either (although I might be missing something, not being familiar with it). I guess being “simple,” it is perfect for quickly read an xml file, but no so much to produce xml. You’ll probaby have to turn to something slightly “heavier” like XML_Serializer.

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

Sidebar

Related Questions

UPDATE 3: I created a Visual Studio 2008 test project and tried to create
I am very, very new to MYSQL.I tried to create a table named option.
I have tried to find how to create DLL-s on linux using google, but
how to create a shortcut for a exe from a batch file. i tried
I want to create a list out of an xml file where only values
I'd like to read a large XML file that contains over a million small
I'm trying to embed a PDF file into a Word document using the OLE
EDIT: See my working code in the answers below. In brief: I have a
I'm working on a blackberry project using eclipse and bb-ant tools. I've created a
I am trying to create a jar file off of a class and xml

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.