Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with XSD Schema when reading XML
Message
From
26/02/2008 22:46:12
 
General information
Forum:
ASP.NET
Category:
XML
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01294005
Message ID:
01296721
Views:
10
>So far I could not make the .ReadXmlSchema work in my code. But I need to do more testing. What I do is call .ReadXmlSchema() and then .ReadXml() but I think I need to find the right parameter for the .ReadXml() in order for it all to work. I will let you know if/when I will make the entire routine successfully working.

Well, as I showed in the code I posted, I used the XmlReadMode.InferSchema. Nothing else seemed to work correctly. The only thing I did not have in my schema though was defaults, which I know was the whole purpose of what you were trying to do.

But anyway ... I'm assuming then that the InferSchema did not work for you as far as the default values go?

~~Bonnie


>
>Thank you.
>
>>You're welcome, Dmitry ... have you had a chance to try this yet?
>>
>>~~Bonnie
>>
>>
>>
>>>Bonnie,
>>>
>>>Thank you very much for your message. I will try your suggestion. I didn't know of the method .ReadXmlSchema and from the example you posted, it should work. I actually just came back from the customer site installing the program without the schema file because I never could get it to work. But if your suggestion works, it will streamline my code by eliminating a bunch of TRY/CATCH.
>>>
>>>Again, thank you.
>>>
>>>>Dmitry,
>>>>
>>>>I tried that too and it didn't work. But, what will probably work is to first load the schema, then read the XML ... like this:
>>>>
>>>>
>>>>this.oDataFromXML.ReadXmlSchema("TestDataSet_XSD_Test.xsd");
>>>>this.oDataFromXML.ReadXml("TestDataSet_XSD_Test.xml", XmlReadMode.InferSchema)
>>>>
>>>>
>>>>I didn't test with any defaults or anything though in my .xsd, so I'm not sure if this will work for what you're trying to do, but give it a try.
>>>>
>>>>~~Bonnie
>>>>
>>>>
>>>>
>>>>
>>>>>I thought this thing was working last night and I should have just retired at that point <g>, but now I am having a problem again.
>>>>>
>>>>>Maybe someone sees what I am missing.
>>>>>
>>>>>I am trying to load an XML into a dataset. I created XML, then created XSD Schema. Then I load the XML as following code:
>>>>>
>>>>>
>>>>>DataSet dstEmailList;
>>>>>dstEmailList.ReadXml(@cEmailListXmlFileName);
>>>>>// The cEmailListXmlFileName has a valid XML file name.
>>>>>
>>>>>
>>>>>The problem is that the above code ignores the XSD file completely. I tried to modify the XSD file entering some garbage but I get no error on the ReadXml. The main issue is that the data types are not set correctly in the dataset because they are specified in the XSD file, which is being ignored.
>>>>>
>>>>>Here is the segment of the top of XML file where I specify the XSD:
>>>>>
>>>>>
>>>>><?xml version="1.0" encoding="utf-8" ?>
>>>>><EmailList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>>	xsi:noNamespaceSchemaLocation="EmailList.xsd" >
>>>>>
>>>>>
>>>>>Here is the top of the EmailList.xsd file:
>>>>>
>>>>>
>>>>><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
>>>>>	<xsd:element name="EmailList">
>>>>>
>>>>>
>>>>>Do you see anything wrong in the above code or the XML files?
>>>>>
>>>>>Thank you in advance for any help.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform