Here's a thought. Instead of using %config% why not use %/software/settings/config% and that way you can use it as the parameter to doc.SelectSingleNode() ? You might save yourself a step or two.
You know, I'm doing something similar myself. If you bug me enough, I might just zip up and post my XML-to-object graph code, though I make to guarantees about its security, performance, or bugs.
Given something like
<Button Text="Click Me">
It will give you what you expect. Just pass in an XmlNode and you get an object back.
To do the scripting bit, you can probably just make a set of scripting objects and have all the text parsing done there.
Oh wow.. can do that?
Hi Sk3rlath, your codes look similar to wfml .. windows form markup language.. released in windowsform.net (i think so???)
Ok, i assume this is what i can do for scripting.
1. Load the xml file.
2. Validate the xml file for syntax and based on the proper schemas.
3. Deserialize the xml file on the fly into cs code(but how can i do that, i know how to do manually with xsd.exe tool ??? ).
4. Compile the c# code on the fly with CodeDom.Compiler.
Then execute the functions.
Am i right? I felt a bit weird with my procedures...
I am not 100% sure what you are trying to achieve. Are you trying to de-serialize an XML document straight into a C# object? If so, Look at the System.Xml.XmlSerializer class, it can do what you want but you will have to change the format of your XML or
transform your XML first into something the XmlSerializer can understand.
If you are just trying to parse an XML document however to load some config settings you should probably start looking in the System.Xml namespace particularly System.Xml.XmlDocument.
Upon further reading of your post, it seems like you may be trying to do something similar to what the NAnt build tool does? (http://nant.sourceforge.net) It essentially executes a build script written in XML.
In that case, I don't believe my advice helps you very much, and I would suggest looking at some of the NAnt source code.
Thanks for the reply.
I had looked into wfml parser.. i think that the parser is a good start for me.
<!-- how do i specify which device id attribute either A1 or B3 ??? -->
Any help please?
Why not use XPath?
It'd become something like this:
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.