php 不允许匹配“[xX][mM][lL]”的处理指令目标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7939426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The processing instruction target matching "[xX][mM][lL]" is not allowed
提问by Passionate Engineer
I'm outputting XML in CakePHP. But I'm getting this error when I put my XML into a validator:
我在 CakePHP 中输出 XML。但是当我将 XML 放入验证器时出现此错误:
The processing instruction target matching "[xX][mM][lL]" is not allowed.
I am using correct XML layout with <?php echo $this->Xml->header(); ?>
at the top then <?php echo $content_for_layout; ?>
我<?php echo $this->Xml->header(); ?>
在顶部使用正确的 XML 布局<?php echo $content_for_layout; ?>
My results are:
我的结果是:
<?xml version="1.0" encoding="UTF-8" ?><response type='' outcome='true' message='Login successful!'>
<user id='1234' total_number_of_completed_tasks='0' total_number_of_declined_tasks='0' total_number_of_passed_tasks='1' total_number_of_failed_tasks='1' reputation_points='99' deviant_points='0' />
<tasks>
<accepted>
<accepted_task id='4' type='Good' time_limit='500' details='Good accepted' />
<accepted_task id='5' type='OK' time_limit='660' details='Ok New task' />
<accepted_task id='9' type='Excellent' time_limit='2000' details='Great failed task' />
<accepted_task id='11' type='Your type' time_limit='222' details='Running and swimming all the way to Japan' />
<accepted_task id='7' type='Man' time_limit='744' details='My dirty task' />
</accepted>
<pending>
<pending_task id='8' type='Women' time_limit='5151' details='Women new task' sender_id='11111' sent_date='2031-01-01 00:00:00' sender_name='Jae Choi' />
</pending>
<completed>
</completed>
<new>
<new_task id='5' type='OK' time_limit='660' details='Ok New task' />
<new_task id='8' type='Women' time_limit='5151' details='Women new task' />
<new_task id='4' type='Good' time_limit='500' details='Good accepted' />
<new_task id='10' type='Hello' time_limit='122' details='What is this?' />
<new_task id='3' type='Best' time_limit='880' details='Stop doing work!' />
<new_task id='11' type='Your type' time_limit='222' details='Running and swimming all the way to Japan' />
<new_task id='6' type='Great' time_limit='553' details='Great accepted task' />
<new_task id='7' type='Man' time_limit='744' details='My dirty task' />
<new_task id='9' type='Excellent' time_limit='2000' details='Great failed task' />
</new>
</tasks>
</response>
Is there anything wrong with this?
这有什么问题吗?
回答by Pops
marmalad and El Boletaire Underave are right that you can't start with a space, but that's not the full story. According to the XML spec, you can't have anything at all before the XML prolog.
marmalad 和 El Boletaire Underave 是正确的,你不能从一个空间开始,但这不是完整的故事。根据XML 规范,在 XML prolog 之前你不能有任何东西。
Since you are using an XML declaration, you must start your file with
由于您使用的是 XML 声明,因此您的文件必须以
<?xml version="1.0" ...
In some cases, non-printing characters like the byte order mark (BOM)can cause trouble by taking up the first few bytes of a file.
在某些情况下,像字节顺序标记 (BOM)这样的非打印字符会占用文件的前几个字节,从而导致麻烦。
For a problem more specific to CakePHP, check to see that you don't have stray blank lines/whitespace at the start or end of your files (i.e. after your ?>
or before your <?php
).
对于更特定于 CakePHP 的问题,请检查文件的开头或结尾处(即在您的 之后?>
或之前<?php
)是否没有杂散的空行/空格。
回答by Martin Taleski
As El Boletaire Underave said, check if the XML is generated without any blank space at the beggining. this help me with my xml.
正如El Boletaire Underave 所说,检查生成的 XML 是否在开始时没有任何空格。这对我的 xml 有帮助。
回答by Durga Prasad Davili
Check Your XML file, it might start with a blank space. If your XML file begins with blank spaces this type of Exception will be thrown.
检查您的 XML 文件,它可能以空格开头。如果您的 XML 文件以空格开头,则会抛出这种类型的异常。
回答by Mujtaba Zaidi
before <?xml ?>
tag u should not have any space.
this tag should be on first line.
this worked for me
在<?xml ?>
标签之前你不应该有任何空间。这个标签应该在第一行。这对我有用