
Signature
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
The problem with FOR XML is that I can not get exactly the xml I want, since
data are from several tables and the fields are dynamic, it is a pain to
create a dynamic explicit for xml statement, isn't it? and in some
situation, FOR XML is just not enough. I think the way I use is more
flexible. Am I right?
> > my question is is there a more efficient way to create xmldocument from data
> > records? if my way is ok, how can I filter out invalid characters and create
[quoted text clipped - 3 lines]
> load XmlDocument or XPathDocument.
> Alternativelky take a look at XmlDataDocument class and DataSet.
Oleg Tkachenko - 10 Dec 2003 16:51 GMT
> The problem with FOR XML is that I can not get exactly the xml I want, since
> data are from several tables and the fields are dynamic, it is a pain to
> create a dynamic explicit for xml statement, isn't it? and in some
> situation, FOR XML is just not enough. I think the way I use is more
> flexible. Am I right?
Building XML using string concatenation is not really good idea either.
Take a look at DataSet, it looks exactly what you are looking for.

Signature
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
David Meyer - 23 Dec 2003 20:24 GMT
Yo Gents,
I think you should check the following out, let me know if it works for
you.
David
// build an Xml string using the StringBuilder
public static String BuildXml2(Int32 Reps)
{
// make sure that the StringBuilder capacity is
// large enough for the resulting text
StringBuilder oSB = new StringBuilder(Reps * 165);
oSB.Append("<Orders method=\"2\">");
for( Int32 nRep = 1; nRep<=Reps; nRep++ )
{
oSB.Append("<Order orderId=\"");
oSB.Append(nRep);
oSB.Append("\" orderDate=\"");
oSB.Append(DateTime.Now.ToString());
oSB.Append("\" customerId=\"");
oSB.Append(nRep);
oSB.Append("\" productId=\"");
oSB.Append(nRep);
oSB.Append("\" productDescription=\"");
oSB.Append("This is the product with the Id: ");
oSB.Append(nRep);
oSB.Append("\" quantity=\"");
oSB.Append(nRep);
oSB.Append("\"/>");
}
oSB.Append("</Orders>");
return oSB.ToString();
}
Oleg Tkachenko - 24 Dec 2003 07:50 GMT
> I think you should check the following out, let me know if it works for
> you.
Please, David, dont' recommend such error-prone hacks to users, what's
wrong with XmlTextWriter?

Signature
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog