当我尝试查看动态生成的(PHP)XML文档时,我收到此错误:
XML解析错误:文档元素之后的垃圾 地点:http://dev.leisurepublishing.com/vtc/master.xml.php 第17行,第1列: ^
我用Google搜索并查看了文档,我无法弄清楚出了什么问题,有人可以帮我发现问题吗?
<?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");
?>
答案 0 :(得分:2)
删除除xml
以外的所有PHP标头标签并添加:
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
</head>
答案 1 :(得分:1)
没关系。我发现最后一个require_once()的路径很糟糕,当我修复路径时,解析错误也消失了。