Link to home
Start Free TrialLog in
Avatar of sreejith_y
sreejith_y

asked on

PHP + domdocument + start line expected. <

HI All,

Following is my code for generating an xml with employee details. I am using PHP 5.2.1

      $result = mysql_query ("select * from tblemployee" ) ;
      if (mysql_num_rows($result) != 0)
      {            
            $doc = new DOMDocument('1.0');
            $doc = new DOMDocument;
            $doc->formatOutput = true;
            
            $videolibrary = $doc->createElement("EmpGroup");
            $videolibrary = $doc->appendChild($videolibrary);
            while ($row = mysql_fetch_array($result))
            {
                  $video = $doc->createElement("Group");
                  $video->setAttribute("grp_name" , $row['Emp_Grp']);
                  $video = $videolibrary->appendChild($video);                  
                  
            }
            $xml_string = htmlentities($doc->saveXML());
            echo ("&status=success&output=$xml_string&");
      }

But the script is giving following error.

domdocument - start tag expected <

Please help me.

Thanks in Advance
Avatar of imitchie
imitchie
Flag of New Zealand image

is there a reason for creating this twice?
            $doc = new DOMDocument('1.0');
            $doc = new DOMDocument;
try dropping the first one
Avatar of sreejith_y
sreejith_y

ASKER


I have tried both seperately.. But same error is coming..
ASKER CERTIFIED SOLUTION
Avatar of pmctrek
pmctrek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial