This is a XML Preprocessor which can be used to process your XML file before you use it, to process conditional statements, variables, iteration statements, error/warning, execute command, etc.
<?include path/to/file ?>
$(env.EnvironmentVariable)
$(sys.SystemVariable)
$(var.CustomVariable)
<?if ?>
<?ifdef ?>
<?ifndef ?>
<?else?>
<?elseif ?>
<?endif?>
<?foreach VARNAME in 1;2;3?>
$(var.VARNAME)
<?endforeach?>
<?error "This is error message!" ?>
<?warning "This is warning message!" ?>
<? cmd "echo hello world" ?>
from preprocessor import *
proc = Preprocessor()
proc.load("input.xml")
proc.preprocess()
proc.save("output.xml")
# command line
> python preprocessor.py <input.xml> [output.xml]
# add Preprocessor.cs, PreprocessorCore.cs, PreprocessorExtension.cs, ProcessedStreamEventHandler.cs, IfContext.cs, IfDefEventHandler.cs and IncludedFileEventHandler.cs into your project then
Preprocessor preprocessor = new Preprocessor();
XmlDocument processedXmlDoc = new XmlDocument();
processedXmlDoc = preprocessor.Process(inXml, null);
processedXmlDoc.Save(outXml);
# command line
> XMLPreprocessor.exe <input.xml> [output.xml]