Is it possible to define variables in an XML file?
For example:
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>
You can use the format string method. You can specify the positional/keyword arguments in your xml file. While making the requests call, you can pass the values for those arguments.
All XML documents must contain a single tag pair to define a root element. All other elements must be within this root element. All elements can have sub elements (child elements). Sub elements must be correctly nested within their parent element.
XML (Extensible Markup Language) is used to describe data. The XML standard is a flexible way to create information formats and electronically share structured data via the public internet, as well as via corporate networks.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With