Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a XML command inside that i want to use constant value or variable for a attribute. See the below command.

<Test spec="generatedSpec.xml" name="Check Load Firmware Data Command" reuseLoadedDomain="true">

Now in this file i want to declare a constant and want to use this constant as a value for "spec" attribute of test command.
Posted
Comments
John C Rayan 24-Sep-15 11:22am    
You must understand the XML file is a data file. You can use whatever you want exceptt restricted special characters. If you use Schema for your XML then you could define a constant using "fixed" in an attribute.
John C Rayan 24-Sep-15 11:24am    
What is your problem in using a constant value in spec attribute though?

1 solution

Depending on what you need, you may find DTD entities useful:
XML
<!ENTITY spec "generatedSpec.xml"> 

<test spec="&spec;" name="Check Load Firmware Data Command" reuseloadeddomain="true">
</test>


You can declare entities before your document element.
You can also use entities to include a piece of XML from an external file into your XML.

See more info here[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900