此
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Data [
<!ENTITY data SYSTEM 'data.txt'>
]>
<Data>
&data;
</Data>
结果
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Data (View Source for full doctype...)>
- <Data>
<event start="Nov 5 2012 00:00:00 GMT" link="http://www.washingtonpost.com/wp-srv/onpolitics/watergate/chronology.htm" image="http://www.constitutioncenter.org/timeline/flash/assets/asset_upload_file761_12313.jpg" title="Nixon Elected">Richard Milhous Nixon, the 55-year-old former vice president who lost the presidency for the Republicans in 1960, reclaims it by defeating Hubert Humphrey in one of the closest elections in U.S. history</event>
<event start="June 17 2012 00:00:00 GMT" end="Aug 1 1972" link="http://www.washingtonpost.com/wp-srv/onpolitics/watergate/chronology.htm" image="http://www.utexas.edu/features/archive/2005/graphics/watergate4.jpg" title="Watergate arrests">Five men, one of whom says he used to work for the CIA, are arrested at 2:30 a.m. trying to bug the offices of the Democratic National Committee at the Watergate hotel and office complex.</event>
</Data>
在此过程中是否还要移除顶线?或隐藏它们?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Data [
<!ENTITY data SYSTEM 'data.txt'>
]>
答案 0 :(得分:0)
这样做的一种方法是使用内联DOCTYPE声明和外部实体。这只有在您的XML解析器能够处理DOCTYPE
时才有用<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Data [
<!ENTITY data SYSTEM 'data.txt'>
]>
<Data>
&data;
</Data>
在这种情况下,data.txt
是来自xml文件位置的相对路径,您也可以使用绝对路径,前提是您的XML解析器可以遵循它。