3
我想了解如何使用外部實體,但我錯過了一些東西。如何在XML中使用外部實體?
我有第一個文件,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但輸出看起來像這樣:
<root>
<tmp id="1"/>
<tmp id="2">This is a test</tmp>
</root>
我錯過了什麼?
更新
我顯示通過Firefox和test_entity2.xml鉻
你所做的是正確的。你如何驗證輸出(在瀏覽器中打開XML,通過身份轉換等)?你確定'test_entity'的路徑是正確的嗎? –
「ou [t]看起來像這樣:」。什麼的輸出?您對輸入生成此輸出的過程是什麼樣的?您是如何看待輸出的? –
@MadsHansen我確認路徑是正確的。我正在驗證輸出與Firefox和Chrome – Spredzy