How to read the xsd file from within my C#project

Asked

Viewed 540 times

0

I’m validating an xml from an xsd file this way:

XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add("urn:bookstore-schema", @"D:\Arquivo\VoltVarPlanning.xsd");

Validate("D:/Arquivo/Exemplo_Saida.xml", schemaSet);

but I don’t want to fetch my file Voltvarplanning.xsd out of my application, as I am doing:

schemaSet.Add("urn:bookstore-schema", @"D:\Arquivo\VoltVarPlanning.xsd");

That’s why I’ve placed . xsd within the same path as the service that does this validation. However, I’m unable to find the Voltvarplanning.xsd in path, it error, by not finding the file.

I did it that way, but it doesn’t work:

XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add("urn:bookstore-schema", @"\VoltVarPlanning.xsd");

Validate("D:/Arquivo/Exemplo_Saida.xml", schemaSet);

How do I search for xsd, since it is already inside my Solution?

  • Please note that my reply does not help you https://answall.com/a/44245/5846

  • Not exactly because I just want to validate if the format of my xml is in accordance with my xsd. for that I know my schemaSet with my xsd that is in this path schemaSet.Add("urn:bookstore-schema", @"D: Voltvarplanning.xsd file");. But instead of calling my path D: Voltvarplanning.xsd file, I want to do from within my own Solution, because I already own my Voltvarplanning.xsd inside the same directory of the service where I do this validation. I don’t know if I could understand my doubt.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.