How XML files with attributes are handled by the System.Data.Dataset.ReadXml Method
How XML files with attributes are handled by the System.Data.Dataset.ReadXml Method
A simple XML file with two different elements, each element with one attribute is used as an example (the values are just for test purposes and are not realistic):
[pastacode lang=”markup” manual=”%3CCompressorDoc%20xmlns%3Ap%3D%E2%80%9Dhttp%3A%2F%2Fprocess-support.com%2Fsystemdesignschema%E2%80%9D%3E%0A%20%20%20%20%3Cp%3ACompressorDocType%3E%0A%20%20%20%20%20%20%20%20%3Cp%3ATag%3E23-KA%20001%3C%2Fp%3ATag%3E%0A%20%20%20%20%20%20%20%20%3Cp%3ATagDescription%3EFirst%20stage%20recompressor%3C%2Fp%3ATagDescription%3E%0A%20%20%20%20%20%20%20%20%3Cp%3ADesignPressure%20Unit%3D%E2%80%9Dbarg%E2%80%9D%3E100.1%3C%2Fp%3ADesignPressure%3E%0A%20%20%20%20%20%20%20%20%3Cp%3AMaxDesignTemperature%20Unit%3D%E2%80%9DC%E2%80%9D%3E160.0%3C%2Fp%3AMaxDesignTemperature%3E%0A%20%20%20%20%3C%2Fp%3ACompressorDocType%3E%0A%20%20%20%20%3Cp%3ACompressorDocType%3E%0A%20%20%20%20%20%20%20%20%3Cp%3ATag%3E23-KA%20002%3C%2Fp%3ATag%3E%0A%20%20%20%20%20%20%20%20%3Cp%3ATagDescription%3E2nd%20stage%20recompressor%3C%2Fp%3ATagDescription%3E%0A%20%20%20%20%20%20%20%20%3Cp%3ADesignPressure%20Unit%3D%E2%80%9Dbarg%E2%80%9D%3E30.1%3C%2Fp%3ADesignPressure%3E%0A%20%20%20%20%20%20%20%20%3Cp%3AMaxDesignTemperature%20Unit%3D%E2%80%9DC%E2%80%9D%3E140.0%3C%2Fp%3AMaxDesignTemperature%3E%0A%20%20%20%20%3C%2Fp%3ACompressorDocType%3E%0A%3C%2FCompressorDoc%3E” message=”” highlight=”1,3,5,7,9,11,13,15″ provider=”manual”/]
This will create the following tables by default:
Figure 1 Tables generated when reading a table of elements with two attributes
Inspecting these tables, the contents are as follows:
Figure 2 Contents of table “CompressorDocType”
Figure 3 Contents of table “DesignPressure
Figure 4 Contents of table “MaxDesignTemperature”
Diving further into the matter, the table contents are as follows for the first row in table “CompressorDocType:
Figure 5 Row [0] of Table “CompressorDocType”
Column [2] has value 0, which is index in the DesignPressure table and the MaxDesignTemperature table.
Figure 6 Content of row [0] in DesignPressure table
Check of row [1] in the DesignPressure table, the value is 30.1 barg
Figure 7 Content of row [1] in DesignPressure table
In column[2] the index value is 1. Checking index for in the CompressorDocType table the index matches
Figure 8 Content of row [1] in CompressorDocType table
It is the same arrangement for the MaxDesigntemperature table.
Unit is in column [0], value in column [1] and reference to CompressorDocType table is in column [2].
Figure 9 Content of row [0] of MaxDesignTemperature table