XmlWriter Issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fairyprincess18
Forum Newbie
Posts: 21
Joined: Sun Dec 07, 2008 8:54 pm

XmlWriter Issue

Post by fairyprincess18 »

I'm trying to use PHP to generate an xml document using the XmlWriter class and am getting the following error:

XML Parsing Error: junk after document element
Location: http://my.wiscnet.net/mashups/imgtoxml.php?
Line Number 2, Column 1:

<table border='1' cellspacing='0'>
^

Here's my code:

Code: Select all

 
<?php
    //begin xml file generation to store marker info
    header('Content-type: application/xml');
    $xml = new XmlWriter();
    $xml->openMemory();
    $xml->startDocument('1.0', 'UTF-8');
    $xml->startElement('markers');
 
    //write xml element
    $xml->startelement('marker');
    $xml->writeCData("some text");
    $xml->endElement();
 
    //end of document and output
    $xml->endElement();
    $xml->endElement();
    echo $xml->outputMemory(true);
?>
 
Anyone know what's wrong?
ben.artiss
Forum Contributor
Posts: 116
Joined: Fri Jan 23, 2009 3:04 pm

Re: XmlWriter Issue

Post by ben.artiss »

Is HTML allowed in XML? You might want to check the class to see what it's outputting- or is it one of those classes you dare not look at in fear of your eyes bleeding?
Post Reply