A
Andrius
Hello,
having some problems by writing XML file by XML schema.
using strongly typed datasets.
Schema:
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="types.xsd" />
<xs:element name="CharactList">
<xs:complexType>
<xs:sequence>
<xs:elementname="Charact"maxOccurs="unbounded">
<xs:complexType> <xs:sequence>
<xs:element name="Id" type="Id" /> <xs:element
name="Did" type="Id" />
<xs:element name="Operation" type="Operation" />
<xs:element name="DateFrom" type="ISODate" />
<xs:element name="Characteristics">
<xs:complexType>
<xs:sequence>
<xs:element name="RiskGroup" type="RiskGroup" minOccurs="0" />
<xs:element name="Interest" type="Interest" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
C# code:
// xml schema compiled to dll
CharactList charactDS = new CharactList();
SqlDataAdapter charactCMD = new SqlDataAdapter(q1, lizingConn);
int i = charactCMD.Fill(charactDS, "Charact");
richTextBox1.Text+= "Rows:" + i;
charactDS.WriteXml("Charact.xml", XmlWriteMode.WriteSchema);
....
Everything is working, but generated new XML file isn't what i need:
<Charact>
<Id>4648</Id>
<Did>14252</Did>
<Operation>COR</Operation>
<DateFrom>2004-12-31</DateFrom>
</Charact>
It must be like this:
<Charact>
<Id>4648</Id>
<Did>14252</Did>
<Operation>COR</Operation>
<DateFrom>2004-12-31</DateFrom>
<Characteristics>
<Interest>4.265</Interest>
</Characteristics>
</Charact>
SQL statement is good, it returns Interest and RiskGroup values, how
to put those values to XML?
SQL:
SELECT
SutCSutId AS Id,
SutCIstId AS Did,
SutCOper AS Operation,
Convert(Char(10),SutCDate,126) AS DateFrom
Convert(Decimal(18,3),SutCVerte*100) AS Interest,
SutCRizika AS RiskGroup
FROM
SutCharacter AS chr
INNER JOIN Sutartys AS sut
ON chr.SutCSutId = sut.SutId
WHERE
SutCOper <> 'DEF' AND
SutTipas <> 'SV' AND
SutBusena IS NULL AND
SutCIstId IS NOT NULL
;
Sorry, I am new with XML.
thanks for help.
having some problems by writing XML file by XML schema.
using strongly typed datasets.
Schema:
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="types.xsd" />
<xs:element name="CharactList">
<xs:complexType>
<xs:sequence>
<xs:elementname="Charact"maxOccurs="unbounded">
<xs:complexType> <xs:sequence>
<xs:element name="Id" type="Id" /> <xs:element
name="Did" type="Id" />
<xs:element name="Operation" type="Operation" />
<xs:element name="DateFrom" type="ISODate" />
<xs:element name="Characteristics">
<xs:complexType>
<xs:sequence>
<xs:element name="RiskGroup" type="RiskGroup" minOccurs="0" />
<xs:element name="Interest" type="Interest" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
C# code:
// xml schema compiled to dll
CharactList charactDS = new CharactList();
SqlDataAdapter charactCMD = new SqlDataAdapter(q1, lizingConn);
int i = charactCMD.Fill(charactDS, "Charact");
richTextBox1.Text+= "Rows:" + i;
charactDS.WriteXml("Charact.xml", XmlWriteMode.WriteSchema);
....
Everything is working, but generated new XML file isn't what i need:
<Charact>
<Id>4648</Id>
<Did>14252</Did>
<Operation>COR</Operation>
<DateFrom>2004-12-31</DateFrom>
</Charact>
It must be like this:
<Charact>
<Id>4648</Id>
<Did>14252</Did>
<Operation>COR</Operation>
<DateFrom>2004-12-31</DateFrom>
<Characteristics>
<Interest>4.265</Interest>
</Characteristics>
</Charact>
SQL statement is good, it returns Interest and RiskGroup values, how
to put those values to XML?
SQL:
SELECT
SutCSutId AS Id,
SutCIstId AS Did,
SutCOper AS Operation,
Convert(Char(10),SutCDate,126) AS DateFrom
Convert(Decimal(18,3),SutCVerte*100) AS Interest,
SutCRizika AS RiskGroup
FROM
SutCharacter AS chr
INNER JOIN Sutartys AS sut
ON chr.SutCSutId = sut.SutId
WHERE
SutCOper <> 'DEF' AND
SutTipas <> 'SV' AND
SutBusena IS NULL AND
SutCIstId IS NOT NULL
;
Sorry, I am new with XML.
thanks for help.