tags:

views:

2324

answers:

1

I am getting this error when I try to view my dynamically generated (PHP) XML document:

XML Parsing Error: junk after document element Location: http://dev.leisurepublishing.com/vtc/master.xml.php Line Number 17, Column 1: ^

I have googled and looked through the document and I can't figure out what's wrong, can someone help me spot the problem?

<?php

header("Content-type: text/xml");
require_once("admin/assets/db_connect.php");

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
?>

<master> 

<categories>
    <category>
     <gsm>GFoo</gsm>
     <category_id>1</category_id>
    </category>
    <category>
     <gsm>SFoo</gsm>
     <category_id>2</category_id>
    </category>
    <category>
     <gsm>MFoo</gsm>
     <category_id>3</category_id>
    </category>
</categories>

<region_codes>
    <code>
     <code_id>11000</code_id>
     <code_name>Central</code_name>
    </code>
    <code>
     <code_id>12000</code_id>
     <code_name>Eastern</code_name>
    </code>
    <code>
     <code_id>13000</code_id>
     <code_name>Western</code_name>
    </code>
    <code>
     <code_id>14000</code_id>
     <code_name>Northern</code_name>
    </code>
</region_codes>

<headers>
    <header>
     <header_id>1</header_id>
     <header_name>Featured A</header_name>
    </header>
    <header>
     <header_id>2</header_id>
     <header_name>Featured B</header_name>
    </header>
    <header>
     <header_id>3</header_id>
     <header_name>Featured C</header_name>
    </header>
</headers>

<advertisers>
    <partner>
     <name>Crestline</name>
     <file>crestline.asp</file>
     <logo>microsites/crestline/logo.jpg</logo>
     <blurb>blah blah blah.</blurb>
     <cat>3</cat>
     <region>15000</region>
     <header_type>1</header_type>
    </partner>
    <partner>
     <name>Example 2</name>
     <file>example2.asp</file>
     <logo>microsites/meeting/example2.jpg</logo>
     <blurb>example 2 example 2 example 2 example 2 example 2 example 2 example 2 example 2 example 2 .</blurb>
     <cat>2</cat>
     <region>14000</region>
     <header_type>1</header_type>
    </partner>
    <partner>
     <name>Example 3</name>
     <file>example3.asp</file>
     <logo>microsites/meeting/example3.jpg</logo>
     <blurb>example 3 example 3 example 3 example 3 example 3 example 3 .</blurb>
     <cat>3</cat>
     <region>11000</region>
     <header_type>1</header_type>
    </partner>
  <partner>
    <name>Example 4</name>
    <file>example4.asp</file>
    <logo>microsites/meeting/example4.jpg</logo>
    <blurb>example 4 example 4 example 4 example 4 example 4 example 4.</blurb>
    <cat>1</cat>
    <region>11000</region>
    <header_type>1</header_type>
  </partner>
  <partner>
    <name>Example 5</name>
    <file>example5.asp</file>
    <logo>microsites/meeting/example5.jpg</logo>
    <blurb>example 5 example 5 example 5 example 5 example 5 example 5.</blurb>
    <cat>1</cat>
    <region>11000</region>
    <header_type>1</header_type>
  </partner>

  <partner>
    <name>Example 6</name>
    <file>example6.asp</file>
    <logo>microsites/meeting/example6.jpg</logo>
    <blurb>example 6 example 6 example 6 example 6 example 6 example 6.</blurb>
    <cat>2</cat>
    <region>11000</region>
    <header_type>2</header_type>
  </partner>
  <partner>
    <name>Example 7</name>
    <file>example7.asp</file>
    <logo>microsites/meeting/example7.jpg</logo>
    <blurb>example 7 example 7 example 7 example 7 example 7 example 7.</blurb>
    <cat>3</cat>
    <region>11000</region>
    <header_type>3</header_type>
  </partner>

  <partner>
    <name>Example 8</name>
    <file>example8.asp</file>
    <logo>microsites/meeting/example8.jpg</logo>
    <blurb>example 8 example 8 example 8 example 8 example 8 example 8.</blurb>
    <cat>1</cat>
    <region>11000</region>
    <header_type>3</header_type>
  </partner>

  <partner>
    <name>Example 9</name>
    <file>example9.asp</file>
    <logo>microsites/meeting/example9.jpg</logo>
    <blurb>example 9 example 9 example 9 example 9 example 9 example 9.</blurb>
    <cat>1</cat>
    <region>11000</region>
    <header_type>3</header_type>
  </partner>

  <partner>
    <name>Example 10</name>
    <file>example10.asp</file>
    <logo>microsites/meeting/example10.jpg</logo>
    <blurb>example 10 example 10 example 10 example 10 example 10 example 10.</blurb>
    <cat>1</cat>
    <region>12000</region>
    <header_type>2</header_type>
  </partner>

</advertisers>

</master>

<?php

require_once("admin/assets/db_disconnect.php");

?>
+1  A: 

Nevermind. I found that the path to the last require_once() was bad and when I fixed the path the parse error went away too.

Marty
Yes, PHP probably output an error about the bad path, that therefore appeared after closing root element, hence the 'junk' error: you're not supposed to have anything after the root element.
Ölbaum