EDN Admin
Well-known member
hi all,
I need some guidance to read xml betterway with xsd in dynamic way.
I analysed best practices for reading and writing xml and find XMLValidatingReader as good one beacuse of my xsd criteria. I need some guidance to design xsd and read the xml in fast and better way.
xml generated from other ERP systems with data. I need to read the xml (from directory ) based on the xsd and process to the database.
I have one business entity for the xml packet which includes
ID, Field1, Field2 Field3 etc
I need to bind this entity when reading xml so that i pass this business object to my business method and DAL respectively.
1. How i design the xsd in better way?
2. I wrote the code as follows
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; while (reader.Read())
{
<span style="color:Blue; switch (reader.NodeType)
{
<span style="color:Blue; case XmlNodeType.Element:
<span style="color:Blue; if (reader.Name == <span style="color:#A31515; "CARRNAME")
{
label1.Text += reader.Name + <span style="color:#A31515; " = ";
reader.Read();
<span style="color:Blue; if (reader.HasValue)
{
label1.Text += reader.Value + Environment.NewLine;
}
}
<span style="color:Blue; break;
}
}
[/code]
I this code, instead of label i just assign the value to the entity. Is this good way to read the xml and bind in properties. But here i need to check each field with if condition and bind to the particular property. Any dynamic method for this so that the
same can be used for all data xmls..
Existing model not used any layered archictecture so no any properties just use DOM and read node with node inxes and call the stored procedure and bind the node value as paramater. I need to change this to layared archictecture and best way.
Anyway reading xml is using ThredPool.UserQueueWorkItem() so that multithreading is enabled to process data as soon as possible
View the full article
I need some guidance to read xml betterway with xsd in dynamic way.
I analysed best practices for reading and writing xml and find XMLValidatingReader as good one beacuse of my xsd criteria. I need some guidance to design xsd and read the xml in fast and better way.
xml generated from other ERP systems with data. I need to read the xml (from directory ) based on the xsd and process to the database.
I have one business entity for the xml packet which includes
ID, Field1, Field2 Field3 etc
I need to bind this entity when reading xml so that i pass this business object to my business method and DAL respectively.
1. How i design the xsd in better way?
2. I wrote the code as follows
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; while (reader.Read())
{
<span style="color:Blue; switch (reader.NodeType)
{
<span style="color:Blue; case XmlNodeType.Element:
<span style="color:Blue; if (reader.Name == <span style="color:#A31515; "CARRNAME")
{
label1.Text += reader.Name + <span style="color:#A31515; " = ";
reader.Read();
<span style="color:Blue; if (reader.HasValue)
{
label1.Text += reader.Value + Environment.NewLine;
}
}
<span style="color:Blue; break;
}
}
[/code]
I this code, instead of label i just assign the value to the entity. Is this good way to read the xml and bind in properties. But here i need to check each field with if condition and bind to the particular property. Any dynamic method for this so that the
same can be used for all data xmls..
Existing model not used any layered archictecture so no any properties just use DOM and read node with node inxes and call the stored procedure and bind the node value as paramater. I need to change this to layared archictecture and best way.
Anyway reading xml is using ThredPool.UserQueueWorkItem() so that multithreading is enabled to process data as soon as possible
View the full article