我可以在 XML 文件中使用变量吗? [英] Can I use variables in XML files?

查看:133
本文介绍了我可以在 XML 文件中使用变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 XML 文件中定义变量?

Is it possible to define variables in an XML file?

例如:

VARIABLE = 'CHIEF_NAME'

    <foods>
      <food>
        <name>French Toast</name>
        <price>$4.50</price>
        <calories>600</calories>
        <chief>VARIABLE</chief>
      </food>
      <food>
        <name>Homestyle Breakfast</name>
        <price>$6.95</price>
        <calories>950</calories>
        <chief>VARIABLE</chief>
      </food>
    </foods>

推荐答案

您可以声明一个 实体引用 并将其引用为 &chief;:

You can declare an entity reference for chief and reference it as &chief;:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE foods [
  <!ENTITY chief "CHIEF_NAME!">
  <!-- .... -->
]>
<foods>
  <food>
    <name>French Toast</name>
    <price>$4.50</price>
    <calories>600</calories>
    <chief>&chief;</chief>
  </food>
  <food>
    <name>Homestyle Breakfast</name>
    <price>$6.95</price>
    <calories>950</calories>
    <chief>&chief;</chief>
  </food>
</foods>

这篇关于我可以在 XML 文件中使用变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆