MSXML to System.Xml Conversion - Schema Equivalents
-
Wednesday, October 10, 2012 9:53 AM
Hi ,
I'm trying to convert a project from VB6 to C#. Trying to convert all MSXML2 elements to System.Xml. However i couldnt find the equivalent of ISchemaModelGroup , XMLSchemaCache60, ISchemaItem, ISchemaType, SOMITEMTYPE. Also i couldnt find the equivalent of nodeTypedValue in System.Xml.XmlNode , namespaces in System.xml.XmlDocument . Can somebody help me with this?
All Replies
-
Wednesday, October 10, 2012 10:15 AM
The SOM (schema object model) implementation in the .NET framework sits in http://msdn.microsoft.com/en-us/library/system.xml.schema.aspx. The APIs are however not quite the same as in MSXML's COM based implementation. The closest to XmlSchemaCache is now http://msdn.microsoft.com/en-us/library/system.xml.schema.xmlschemaset.aspx. As for model group, that is represented by http://msdn.microsoft.com/en-us/library/system.xml.schema.xmlschemagroup.aspx I think. I think if you want to port code using MSXML to .NET that involves validating instance documents against W3C schemas then you should start with reading http://msdn.microsoft.com/en-us/library/hdf992b8.aspx.
As for nodeTypedValue, is that used with MSXML and W3C schemas, or only with XDR schemas?
Currently with .NET if you want a typed value for nodes in a tree model then XPathNavigator has support for that, see http://msdn.microsoft.com/en-us/library/system.xml.xpath.xpathnavigator.typedvalue.aspx.
MVP Data Platform Development My blog
-
Thursday, October 11, 2012 6:18 AM
Thanks for the reply
I have a code like this
internal static void WriteValueToNode(System.Xml.XmlNode node, string value)
{
if (node.ChildNodes.Count > 1)
{
node = node.ChildNodes[0];
}
if (value.ToUpper() == "#NULL")
{node.nodeTypedValue = ""; }
else
{
node.nodeTypedValue = value; }}
i couldnt find an equivalent for the nodeTypedValue.
-
Thursday, October 11, 2012 9:16 AM
As long as you want to set the string contents of an element you can simply set http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.innertext.aspx:
node.InnerText = "";
respectively
node.InnerText = value;
MVP Data Platform Development My blog

