Click here to Skip to main content
15,904,416 members
Home / Discussions / C#
   

C#

 
GeneralRe: XML Bulk Loader (SQLXML 3.0) Pin
perlmunger6-Jan-05 5:37
perlmunger6-Jan-05 5:37 
GeneralInfragistics UltraCalendarInfo control Pin
eliea6-Jan-05 1:45
eliea6-Jan-05 1:45 
GeneralRe: Infragistics UltraCalendarInfo control Pin
Nick Parker6-Jan-05 6:50
protectorNick Parker6-Jan-05 6:50 
Generalmodifying xml field data's using c# Pin
dhol6-Jan-05 1:42
dhol6-Jan-05 1:42 
GeneralRe: modifying xml field data's using c# Pin
perlmunger6-Jan-05 5:43
perlmunger6-Jan-05 5:43 
GeneralRe: modifying xml field data's using c# Pin
dhol6-Jan-05 16:38
dhol6-Jan-05 16:38 
GeneralRe: modifying xml field data's using c# Pin
perlmunger7-Jan-05 6:27
perlmunger7-Jan-05 6:27 
GeneralRe: modifying xml field data's using c# Pin
dhol7-Jan-05 17:05
dhol7-Jan-05 17:05 
Hi I have done a program in c# such that , my program reads a schema file and automatically loads data into a xml file.

ex:we hav e a text box where we give a schema file.
let us give the following schena file
consider the following schema


<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns:xs="http://://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="en-AU">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="vw_forecast">
<xs:complexType>
<xs:sequence>
<xs:element name="billto_name" type="xs:string" minOccurs="0" />
<xs:element name="dividend" type="xs:float" minOccurs="0" />
<xs:element name="section" type="xs:double" minOccurs="0" />

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
</NewDataSet>


We can see that there are three fields namely billto_name, dividend and section.
-------------------------------------------------------------------------
we have another textbox, where we give a path and a newname xml file . where we get the result.
after giving giving the path where we want to save and the new xml file name and we click a button named load. then values get loaded into the new xml file automatically

so my program reads this schema file and loads data automatically by obtaining the following xml file


<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="en-AU">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="vw_forecast">
<xs:complexType>
<xs:sequence>
<xs:element name="billto_name" type="xs:string" minOccurs="0" />
<xs:element name="dividend" type="xs:float" minOccurs="0" />
<xs:element name="section" type="xs:double" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<vw_forecast>
<billto_name>Castle Hampers0</billto_name>
<dividend>4.5</dividend>
<section>888888</section>
</vw_forecast>
<vw_forecast>
<billto_name>Castle Hampers1</billto_name>
<dividend>5.5</dividend>
<section>888889</section>
</vw_forecast>
<vw_forecast>
<billto_name>Castle Hampers2</billto_name>
<dividend>6.5</dividend>
<section>888888</section>
</vw_forecast>
<vw_forecast>
<billto_name>Castle Hampers3</billto_name>
<dividend>7.5</dividend>
<section>8888890</section>
</vw_forecast>
<vw_forecast>
<billto_name>Castle Hampers4</billto_name>
<dividend>8.5</dividend>
<section>888891</section>
</vw_forecast>

</NewDataSet>


we can see the values as castlehampers1,..2..3..4..so on for string datatype and 4.5,5.5,6.5...so on for float..etc...


-----------------------------------------------------------------------

Now my requirement is that I have another xml file in the project directory with a single field name "billto_name". with some meaningful values. So I have to program such that if the schema contains a "billto_name" field then load data's from this xml where we have meaninful fields into the result xml. ie, the previous xml here we obtained data's automatically.
ie, values for billto_name should chanege whereas others should remain unchanged.


this is the xml file with meaninful values. so we should read the values of billto_name from here and load it into the above xml for that particular field.

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="en-AU">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="billtoname">
<xs:complexType>
<xs:sequence>
<xs:element name="billto_name" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<billtoname>
<billto_name>ACCOUNTS CODES ONLY</billto_name>
</billtoname>
<billtoname>
<billto_name>ACCOUNTS CODES ONLY</billto_name>
</billtoname>
<billtoname>
<billto_name>AERIAL PRODUCT RANGE</billto_name>
</billtoname>
<billtoname>
<billto_name>AFL LICENCED PRODUCT</billto_name>
</billtoname>
<billtoname>
<billto_name>AUST RUGBY UNION</billto_name>
</billtoname>
</NewDataSet>

so the values such as AUST RUGBY UNION , AFL LICENCED PRODUCT EVERYTHING SHOUYLD BE INSERTED INTO THE PREVIOUS XML FILE FOR THAT FIELD ALONE.


This is my requirement. I tried a lot but i couldnt suceed

my coding for automatic loading of values is as follows. pls chaneg and sent , as I need this very urgently.

------------------------------------------------------------------
private void button2_Click(object sender, System.EventArgs e)
{
dataSet1.ReadXmlSchema(txtSchema.Text);
//*******txtschema.text is the schema file which we pass
foreach (DataTable dTbl in dataSet2.Tables)
{
object[] oValues = new object[dTbl.Columns.Count];
int i = 0;
foreach (DataColumn dColmn in dTbl.Columns)
{
switch(dColmn.DataType.ToString())
{
case "System.String":
oValues[i] = (string) "sachin" + j;
break;

case "System.Int32":
oValues[i] = (int) 100 + j;
break;
case "System.DateTime":
oValues[i] = new DateTime(2004,01,30).AddDays(j * 1);
break;
case "System.Decimal":
oValues[i] = new Decimal(10000900.99) + j;
break;
}
i += 1;
}
dTbl.Rows.Add(oValues);
}
}
}




private void button3_Click(object sender, System.EventArgs e)
{
dataSet2.WriteXml(txtXml.Text, XmlWriteMode.IgnoreSchema );
//***txtxml.text is the xml file which we obtain as the result
MessageBox.Show("Saved");
}



santhosh


GeneralMethod return Value Pin
webhay5-Jan-05 23:43
webhay5-Jan-05 23:43 
GeneralRe: Method return Value Pin
Stefan Troschuetz5-Jan-05 23:59
Stefan Troschuetz5-Jan-05 23:59 
GeneralRe: Method return Value Pin
haimlz6-Jan-05 1:02
haimlz6-Jan-05 1:02 
GeneralRe: Method return Value Pin
Salil Khedkar6-Jan-05 1:07
Salil Khedkar6-Jan-05 1:07 
GeneralXmlDocument Write problems and Add Identation Help! Pin
Chua Wen Ching5-Jan-05 23:40
Chua Wen Ching5-Jan-05 23:40 
GeneralRe: XmlDocument Write problems and Add Identation Help! Pin
Stanimir_Stoyanov6-Jan-05 0:07
Stanimir_Stoyanov6-Jan-05 0:07 
GeneralRe: XmlDocument Write problems and Add Identation Help! Pin
J4amieC6-Jan-05 3:03
J4amieC6-Jan-05 3:03 
GeneralRe: XmlDocument Write problems and Add Identation Help! Pin
Chua Wen Ching6-Jan-05 13:34
Chua Wen Ching6-Jan-05 13:34 
GeneralList View items - exporting and importing data Pin
Stanimir_Stoyanov5-Jan-05 22:43
Stanimir_Stoyanov5-Jan-05 22:43 
GeneralRe: List View items - exporting and importing data Pin
Patric_J6-Jan-05 10:55
Patric_J6-Jan-05 10:55 
GeneralPrint without preview in C# Pin
gbess5-Jan-05 22:39
gbess5-Jan-05 22:39 
Generalimage screensaver with mem probs Pin
Steven_T5-Jan-05 20:41
Steven_T5-Jan-05 20:41 
GeneralRe: image screensaver with mem probs Pin
perlmunger6-Jan-05 6:11
perlmunger6-Jan-05 6:11 
GeneralRe: image screensaver with mem probs Pin
Steven_T6-Jan-05 21:21
Steven_T6-Jan-05 21:21 
GeneralRe: image screensaver with mem probs Pin
Steven_T6-Jan-05 23:23
Steven_T6-Jan-05 23:23 
QuestionHow to get explorer like (custom?) controls. Pin
E_NoName5-Jan-05 16:30
E_NoName5-Jan-05 16:30 
AnswerRe: How to get explorer like (custom?) controls. Pin
Alex Korchemniy5-Jan-05 19:18
Alex Korchemniy5-Jan-05 19:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.