如何在XML中使用外部实体? [英] How to use external entities in XML?
问题描述
我试图了解如何使用外部实体,但是我缺少一些东西。
I am trying to understand how to use external entities, but I am missing something.
我有第一个文件 test_entity.xml >
<?xml version="1.0" encoding="UTF-8" ?>
<test>
<test_1>Inside</test_1>
</test>
和第二个文件 test_entity2.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE root [
<!ENTITY test_entity SYSTEM "/Users/username/test_entity.xml">
<!ENTITY test_string "This is a test">
]>
<root>
<tmp id="1">&test_entity;</tmp>
<tmp id="2">&test_string;</tmp>
</root>
在这里,我试图将test_entity.xml内容嵌入到test_entity2.xml中,但输出看起来像这样:
Here I am trying to embed test_entity.xml content into test_entity2.xml but the ouput looks like this :
<root>
<tmp id="1"/>
<tmp id="2">This is a test</tmp>
</root>
我想念什么?
更新
我正在通过firefox和chrome显示test_entity2.xml
I am displaying test_entity2.xml through firefox and chrome
推荐答案
您正在执行的操作是有效的XML,并将与符合规范且不受安全性限制的XML解析器一起使用。
尝试在IE中查看XML。某些浏览器(例如FireFox和Chrome)具有非常严格的安全设置,并且不会加载文件实体引用和XSLT处理指令,这些指令引用了fileystm上的文件。
Try viewing the XML in IE. Some browsers(like FireFox and Chrome) have very strict security settings and will not load files entity references and XSLT processing instructions that reference files on the filesystm.
这篇关于如何在XML中使用外部实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!