Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Missing XML Nodes [Thread Next] Re: Missing XML NodesTo: NULL Date: 1/6/2009 6:03:00 PM Fred Chateau wrote:
> I have a large amount of XML data, which must be imported into SQL Server.
>
> I wrote a program in C#, which uses XMLReader to read the records and pass the node values into a
> SQL data object. It doesn't work, however, because the XML is structured so that when the value for
> a node is null, the node is missing. This causes the XMLReader to fall through to the next record,
> until it finds a record with the desired node present. Furthermore, although there are schemas
> provided with the data, they cannot be relied on to be an accurate representation of the XML.
>
> Is there another .NET XML technology that would allow me to read these records accurately, with or
> without the provided schemas?
If the W3C XML schema language would be used then null values would not
be represented by missing elements but rather by using e.g.
<xs:element name="foo" type="xs:int" nillable="true"/>
in the schema and e.g.
<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true"/>
in the XML instance document.
As for checking whether a certain element is missing, you can do that
with XPath for instance. So using XPathDocument/XPathNavigator would
allow you to check whether certain child elements exist.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
