Why external system entities are not working for me in Chrome, IE or Netscape?

a 夏天 提交于 2019-12-02 14:12:16

问题


I am attempting to replicate the example given in this answer:

https://stackoverflow.com/a/5127928/356011

that illustrates using external entities to include a fragment of XML file in another XML file.

doc.xml:

<?xml version="1.0" standalone="no" ?>
<!DOCTYPE doc [
        <!ENTITY otherFile SYSTEM "otherFile.xml">
        ]>
<doc>
    <foo>
        <bar>&otherFile;</bar>
    </foo>
</doc>

otherFile.xml:

<baz>this is my content</baz>

When I attempt to test this by opening doc.xml in any browser, I just get:

 <doc>
   <foo>
      <bar/>
    </foo>
 </doc>

rendered.

Shouldn't it be rendering the included file, as well?


回答1:


The reason it isn't working is that browsers don't fully support XML. They only support it with restrictions, such as "no external entities". I don't know why.



来源:https://stackoverflow.com/questions/15650009/why-external-system-entities-are-not-working-for-me-in-chrome-ie-or-netscape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!