deserialize nested ref RRS feed

  • Question

  • Hello.
    I have one question, you can expand the refs  ids nested in an xml with DataContractserializer?
    It 'a life that I try and I try on google but I did not succeed.
    I created the classes with serviceutil but when deserialize the nested ref are not processed.

    <?xml version="1.0" encoding="UTF-8"?>
    <iso_10303_28 version="2.0"
    		<organization>Building Designer Office</organization>
    		<preprocessor_version>Express Data Manager Version 4.7.065 Oct 30 2006</preprocessor_version>
    		<originating_system>Windows System</originating_system>
    		<authorization>The authorising person</authorization>
    		<documentation>ArchiCAD 10.00 Release 1.Build Number of the Ifc 2x3 interface: 63044 (18-04-2007)</documentation>
    	<uos id="uos_1" description="" edo="" configuration="default" xmlns="" xsi:schemaLocation=" IFC2X3.xsd"
    	xmlns:ex="" >
    		<IfcAxis2Placement3D id="i1637">
    				<IfcCartesianPoint id="i1668">
    					<Coordinates cType="list">
    						<IfcLengthMeasure pos="0">0.</IfcLengthMeasure>
    						<IfcLengthMeasure pos="1">0.</IfcLengthMeasure>
    						<IfcLengthMeasure pos="2">0.</IfcLengthMeasure>
    		<IfcOwnerHistory id="i1640">
    				<IfcPersonAndOrganization id="i1656"><!-- not expanded ignored
    						<IfcPerson id="i1650">
    						<IfcOrganization xsi:nil="true" ref="i1652"/>
    				<IfcApplication id="i1659">
    						<IfcOrganization xsi:nil="true" ref="i1652"/>
    		<IfcOrganization id="i1652">
    			<Name>Nemetschek Allplan GmbH</Name>
    		<IfcProject id="i1641">
    				<IfcOwnerHistory xsi:nil="true" ref="i1640"/>
    			<RepresentationContexts cType="set">
    				<IfcGeometricRepresentationContext xsi:nil="true" ref="i1647"/>
    				<IfcGeometricRepresentationContext xsi:nil="true" ref="i1674"/>
    				<IfcUnitAssignment id="i1678">
    					<Units cType="set">
    						<IfcSIUnit id="i1661">
    						<IfcConversionBasedUnit id="i1665">
    								<IfcDimensionalExponents id="i1664">
    								<IfcMeasureWithUnit id="i1663">
    										<IfcSIUnit id="i1662">
    						<IfcSIUnit xsi:nil="true" ref="i1666"/>
    						<IfcSIUnit xsi:nil="true" ref="i1667"/>

    Wednesday, April 20, 2016 8:07 AM


All replies

  • Hello,

    We can use the DataContractSerializer.ReadObject method do the deserialization. The DataContractSerializer.ReadObject method will read the XML stream with an XmlDictionaryReader and returns the deserialized object.

    For the detailed information and example about how to use deserialize the XML using the DataContractSerializer, please try to refer to the following articles: . . .

    Best Regards,
    Amy Peng

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 22, 2016 3:16 AM
  • ok , thanks i reformulate the question:

    I have a xsd and I would like to create the related classes in c # for de-serialization and serialization.
    I would like and this is the problem that the serialization of xml espandesse REF with also nested ID.
    I tried svcutil it puts me the collection of XMLNodes and lxsd.exe ignores me the id and the ref altogether.
    how can I create the typed classes in c # and deserialize expanding the ids and the refs also nested?
    thank you.

    1) which tools should I must use svcutils or xsd.exe
    2) I tried with svcutil but causes me the collections of XMLNodes and not concrete types, maybe I should use xsd.exe and de-serialize with DataContractSerializer?
    I tried everything but I can not.

    Tuesday, May 10, 2016 10:21 PM
  • hello.

    i repost there my question because i have some problem with english

    I would deserialize an xsd for the ifc bim industrial standard.
    I have a custom xmlreader that works fine with xsd.exe and i use it for adapt the little errors in different dialect of ifc cad exporters?but  servcutil creates me a code like:

        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "")]
        [System.Xml.Serialization.XmlRootAttribute(IsNullable = false)]
        internal partial class uos : object, System.Xml.Serialization.IXmlSerializable, System.ComponentModel.INotifyPropertyChanged
            private System.Xml.XmlNode[] nodesField;
            private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("uos", "");
            internal System.Xml.XmlNode[] Nodes
                    return this.nodesField;
                    if ((object.ReferenceEquals(this.nodesField, value) != true))
                        this.nodesField = value;

    it's not typized what are these XMLNODE[]?
    is possible to insert the types indeed of these xmlnode[] and why doesn't have the correct types?.
    I would use the datacontractserializer because it resolve the ids / refs with the ....

    DataContractSerializer dcs = new DataContractSerializer(typeof(ConsoleApplication31.iso_10303_28), null,
                 int.MaxValue ,
                 false ,
                 true /*preserveObjectReferences : this is where the magic happens */,
                 null );

    is possible to resolve the ids / refs with the xsd deserializator in some manner?
    or change the xmlnodes[] to types with srvcutils?


    Friday, July 8, 2016 8:29 AM