|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
not able to read an XSD fileHi,
I have an xsd file. I'm trying to read it into a dataset or even any other collection will do. But the problem is it is not getting read. Also, it is not throwing any error. Kindly help me on the same. Thanks, Pooja Hi Pooja,
Please post the code you're using to try to read the data. Regards, Cerebrus. Hi,
Actually none of my code was working. Still I'll post whatever I tried. Hers is the code: 1. In following code, I'm not able to reach the values of the items. XmlSchema xsd; XmlSchemas schemas = new XmlSchemas(); using(FileStream fs = new FileStream(@"C:\Schemas\CoafPrimitives.xsd", FileMode.Open)) { xsd = XmlSchema.Read(fs, null); xsd.Compile(null); } foreach(XmlSchemaObject xso in xsd.Items) { } 2. In this code, the table count is always 0: XmlDataDocument myXmlDataDocument = new XmlDataDocument(); StreamReader myStreamReader = new StreamReader(@"C:\Schemas\CoafPrimitives.xsd"); myXmlDataDocument.DataSet.ReadXml(myStreamReader); Console.WriteLine("Tables count=" + myXmlDataDocument.DataSet.Tables.Count.ToString()); Please advice. Thanks, Pooja. Hi,
The use of the XmlSchemas class suggests that this is VS 2005 code. In that case, I am unable to help you. I am not yet familiar with the 2005 version of VS. Regards, Cerebrus. Hi,
Thanks for replying. Can you please have a look at the 2nd code. That is not using Schemas. Even I'm working on VS 2003 and not 2005. So you can provide me any code that works for VS 2003, Framework 1.1 Thanks, Pooja. Hi,
As I mentioned, I tried *both* the code fragments, and they work for me. I might be able to help you more if you could describe exactly what you want to do after reading an XSD File... Or post atleast a part of your XSD file, so that I can test the code with that file. Right now I just tested with a sample XSD. For the 1st code segment, using "Console.WriteLine(xso.ToString());" within the foreach loop, I was able to output the types of upper level elements in the file. For the 2nd code segment, I was able to get a Table count of 1. Regards, Cerebrus. Hi,
1. What version of VS are you using ? 2. Are the two segments of code you posted related ? I can see that they're trying to read the same XSD file, but how are they related to each other ? 3. Both your segments of code seem to work for me, so it might be a problem with the xsd file. BTW, don't forget to close your StreamReader after you're done reading. 4. In the first code segment, what do you want to do with each XmlSchemaObject ? Regards, Cerebrus. Hi,
Both the codes are not inter-related. 2nd one is not using Schemas. I'm working on VS 2003 and not 2005. So you can provide me any code that works for VS 2003, Framework 1.1 Thanks, Pooja. Hi again,
I think I might be able to explain it better (and understand you better), if we could chat in real-time. Do you use any sort of instant messenger ? Regards, Cerebrus. |
|||||||||||||||||||||||