<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : writing an entity with child to xml</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : writing an entity with child to xml</description>
  <pubDate>Tue, 12 May 2026 21:26:37 -700</pubDate>
  <lastBuildDate>Tue, 18 Sep 2007 12:18:13 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=432</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>writing an entity with child to xml : Hi, I tried the ado.Net writeXml...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=432&amp;PID=1197#1197</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=60" rel="nofollow">Dominique</a><br /><strong>Subject:</strong> 432<br /><strong>Posted:</strong> 18-Sep-2007 at 12:18pm<br /><br />Hi,<br />I tried the ado.Net writeXml one more time. :-)<br />I managed to somehow serialize the entities to a xml file.<br />The solution I found to pick up wich entities will be written to the file is to:<br />  * create a dataset and clone the myEntity.dataset to get the structure<br />  * make a list of datarows that I will fill by iterating the child collections of the entities<br />  * merge the rows in the dataset<br />  * call the writeXml method<br /><br />The result would require a fair amount of Xquerying because the elements are all under the rotelement "newDataset" (no structure)<br /><br />It wasn't so much work to write my own serializer, and the resulting file is much easier to parse, so I will stick with it. It also make it easier to not expose columns that should remain private.<br /><br />That was the code I wrote, if of any interest... I wouldn't be surprised if it is a very wrong way to do it :). (example with 2 levels of nexting). <br /><table width="99%"><tr><td><pre class="BBcode"><br />Dim path As String = &lt;thePath&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim wrSettings As New XmlWriterSettings()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; With wrSettings<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Indent = True<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Encoding = Text.Encoding.UTF8<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.CloseOutput = True<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.ConformanceLevel = ConformanceLevel.Auto ' must have that<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End With<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim writer As XmlWriter = XmlWriter.Create(path, wrSettings)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using writer<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Dim ds As DataSet = context.Table.DataSet.Clone<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Dim rowList As New List(Of DataRow)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  rowList.Add(context)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  For Each child As MyChild In context.Childs<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rowList.Add(child)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For Each grandchild As grandchild In MyChild.Childs<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rowList.Add(grandchild)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Next<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Dim theRows As DataRow() = rowList.ToArray()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ds.Merge(theRows)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ds.WriteXml(writer, XmlWriteMode.IgnoreSchema)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  writer.Close()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch ex As Exception<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Diagnostics.Debug.Print("Exception from xmlWriter: " & ex.Message) 'to get a good message<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Throw ex&nbsp;&nbsp;&nbsp;' caller's work<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Using<br /></pre></td></tr></table>]]>
   </description>
   <pubDate>Tue, 18 Sep 2007 12:18:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=432&amp;PID=1197#1197</guid>
  </item> 
  <item>
   <title>writing an entity with child to xml : I would think that you would be...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=432&amp;PID=1191#1191</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=23" rel="nofollow">davidklitzke</a><br /><strong>Subject:</strong> 432<br /><strong>Posted:</strong> 18-Sep-2007 at 8:55am<br /><br /><P>I would think that you would be able to use the DataSet.WriteXml method.</P>]]>
   </description>
   <pubDate>Tue, 18 Sep 2007 08:55:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=432&amp;PID=1191#1191</guid>
  </item> 
  <item>
   <title>writing an entity with child to xml : Hi, I want to write a parent-childs...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=432&amp;PID=1189#1189</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=60" rel="nofollow">Dominique</a><br /><strong>Subject:</strong> 432<br /><strong>Posted:</strong> 18-Sep-2007 at 12:22am<br /><br />Hi,<br />I want to write a parent-childs hierarchy as an xml-file. I am wondering if there is a trivial way to achieve this with Ideablade?<br />I actually don't know the dotnet xml-API. I saw yesterday that datatable had method to do that but I didn't achieve my goal wich is basically<br /><table width="99%"><tr><td><pre class="BBcode"><br />sub WriteEntitty(anEntity as MyType)<br />anEntity = persistMng.getEntity(..)<br />anEntity.MagicMethodToXML(path, encoding)<br /></pre></td></tr></table><br />the following structure for the xml file would be perfect:<br /><table width="99%"><tr><td><pre class="BBcode"><br />&lt;parent&gt;<br />&lt;tblColumnname&gt;value&lt;\tblColumnname&gt;<br />&lt;tblColumnname&gt;value&lt;\tblColumnname&gt;<br />  &lt;evt- childtype1s&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;child type1&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tblColumnname&gt;value&lt;\tblColumnname&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/child type1&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;child type1&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tblColumnname&gt;value&lt;\tblColumnname&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/child type1&gt;<br />  &lt;/evt- childtype1s&gt; <br />  &lt;evt- childtype2s&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;child type2&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tblColumnname&gt;value&lt;\tblColumnname&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tblColumnname&gt;value&lt;\tblColumnname&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/child type2&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;child type2&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tblColumnname&gt;value&lt;\tblColumnname&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tblColumnname&gt;value&lt;\tblColumnname&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/child type2&gt;<br />  &lt;/evt- childtype2s&gt; <br />&lt;/parent&gt;<br /></pre></td></tr></table><br /><br />Dominique]]>
   </description>
   <pubDate>Tue, 18 Sep 2007 00:22:17 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=432&amp;PID=1189#1189</guid>
  </item> 
 </channel>
</rss>