如何在XML中嵌入图像?

时间:2017-04-11 18:13:43

标签: html css xml dtd

我想用浏览器打开XML文件并显示数据和徽标图像,但我似乎无法弄清楚如何执行此操作。我已经搜索了很多,但找不到简单的解释,即使我确信它可能很简单。我有三个文件:XML文件,DTD文件和CSS文件。除了图像之外,所有数据都正确显示,据我所知,我已经在XML和DTD文件中正确包含了代码(可能我需要在CSS文件中添加一些内容才能显示它?)。

这是我的(压缩的)XML文件代码:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="CarAcc_13007620.css"?>
<!-- This document contains data on the Car Accessories Shop -->
<!DOCTYPE shop SYSTEM "CarAcc_13007620.dtd"
[
<!ENTITY shoplogo SYSTEM "shoplogo.jpg" NDATA JPG>
]
>

<shop>
<shopname>Car Accessories</shopname>
<address>330 Goswell Road, London, EC1V 7LQ</address>
<telnumber>078502982</telnumber>
<website>https://www.caraccessories123.co.uk</website>
<logo source="shoplogo"/>

<products>

<batterycharger manufacturer="BestBatteries Ltd">
<name>Basic Battery Charger</name>
<itemnumber>P0001</itemnumber>
<description>This basic battery charger will charge batteries quickly and 
efficiently and is great value for money!</description>
<quantity>5</quantity>
<price>&#163; 7.50</price>
</batterycharger>

</products>

</shop>

这是我的DTD文件:

<!ELEMENT shop (shopname, address, telnumber, website, logo, products)>
<!ELEMENT shopname (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT telnumber (#PCDATA)>
<!ELEMENT website (#PCDATA)>
<!ELEMENT logo EMPTY>
<!ATTLIST logo source ENTITY #REQUIRED>

<!ELEMENT products (batterycharger+, seatcover+, carheater+, cupholder+, 
seatorganiser+, bootorganiser+)>

<!ELEMENT batterycharger (name, itemnumber, description, quantity, price)>
<!ATTLIST batterycharger manufacturer CDATA #REQUIRED>

<!ELEMENT seatcover (name, itemnumber, description, quantity, price, color)>
<!ATTLIST seatcover manufacturer CDATA #REQUIRED>

<!ELEMENT carheater (name, itemnumber, description, quantity, price)>
<!ATTLIST carheater manufacturer CDATA #REQUIRED>

<!ELEMENT cupholder (name, itemnumber, description, quantity, price)>
<!ATTLIST cupholder manufacturer CDATA #REQUIRED>

<!ELEMENT seatorganiser (name, itemnumber, description, quantity, price, 
material, color, foldable)>
<!ATTLIST seatorganiser manufacturer CDATA #REQUIRED>
<!ATTLIST seatorganiser tabletholder (Yes | No) #REQUIRED>
<!ATTLIST seatorganiser delivery (Free | Express) #REQUIRED>

<!ELEMENT bootorganiser (name, itemnumber, description, quantity, price, 
material, color, foldable)>
<!ATTLIST bootorganiser manufacturer CDATA #REQUIRED>
<!ATTLIST bootorganiser delivery (Free | Express) #REQUIRED>

<!ELEMENT name (#PCDATA)>
<!ELEMENT itemnumber (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT material (#PCDATA)>
<!ELEMENT color (#PCDATA)>
<!ELEMENT foldable (#PCDATA)>

<!NOTATION JPG SYSTEM "image/jpg">

当我使用任何浏览器启动XML文件时,除了没有显示图像外,它们都正确加载。有什么想法吗?包括图像在内的所有文件都在同一文件夹中。 CSS文件是基本的,只是对齐文本等等,但我没有在CSS文件中包含图像的任何代码,因为我不知道如何处理这种情况或者是否甚至需要它来简单地显示图像首先。任何帮助将不胜感激!谢谢。

0 个答案:

没有答案