简体   繁体   English

使用一个XML文件,如何用单独的XML元素填充不同的页面?

[英]With one XML file, how do I populate different pages with individual XML elements?

Hi was just wondering how I could use one XML file to populate to different files. 您好,我只是想知道如何使用一个XML文件来填充不同的文件。 For example, in the XML below how would I get the first XML block "cooking" to show up on cooking.html and the second XML block "children" to show up on children.html? 例如,在下面的XML中,我如何使第一个XML块“ cooking”显示在cooking.html上,第二个XML块“ children”显示在children.html上? I know how to make them all display on one page but not on individual pages. 我知道如何使它们全部显示在一页上而不显示在单个页面上。

<book category="COOKING">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>

<book category="CHILDREN">
 <title lang="en">Harry Potter</title>
 <author>J K. Rowling</author>
 <year>2005</year>
 <price>29.99</price>
</book>

Thanks! 谢谢!

If you are using some server-side scripting, you could parse only the COOKING-category when requesting cooking.html etc. 如果您使用某些服务器端脚本,则在请求cooking.html等时只能解析COOKING类别。

Though, if you are getting the XML-data directly from the HTML-code, then I would recommend splitting the XML-file by category. 但是,如果您直接从HTML代码获取XML数据,那么我建议按类别拆分XML文件。 Alternately you could have a XML-file which includes separate XML-files sorted by category. 或者,您可以有一个XML文件,其中包括按类别排序的单独XML文件。 Described here. 在这里描述。

Sorry I couldn't give you a better solution. 对不起,我无法为您提供更好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM