Hello.
ParseXSD.cs
using System;
using System.Collections;
using System.Xml;
using System.Xml.Schema;
class XmlSchemaTraverseExample
{
static void Main()
{
// Add the customer schema to a new XmlSchemaSet and compile it.
// Any schema validation warnings and errors encountered reading or
// compiling the schema are handled by the ValidationEventHandler delegate.
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
schemaSet.Add("http://www.w3.org/2001/XMLSchema", "tmp.xsd");
schemaSet.Compile();
// Retrieve the compiled XmlSchema object from the XmlSchemaSet
// by iterating over the Schemas property.
XmlSchema customerSchema = null;
foreach (XmlSchema schema in schemaSet.Schemas())
{
customerSchema = schema;
}
// inserted more code here....
}
}
Currently, my ConsoleApp worked very well.
And i want to remove the hard code (xsd file path) out from my code below.
// i don't know how to update this line.
schemaSet.Add("http://www.w3.org/2001/XMLSchema", "tmp.xsd");
Then i could run my ParseXSD.cs file at the building time with the CSC command below.
// i don't know the correct command format. I could update the path parameter easily. NO hard code.
CSC ParseXSD.cs d:/tmp/tmp.xsd
Please give me some guide. thanks in advance.