Write XML Tree to XML file (LINQ to XML) with sub child

In my article Write XML Tree to XML file (LINQ to XML) http://chanmingman.wordpress.com/2012/07/21/write-xml-tree-to-xml-file-linq-to-xml/ the XElement tree only has on level. In this sample, I added another level to the tree.

  class Program

  {

    static void Main(string[] args)

    {

      XmlWriter xw = XmlWriter.Create(“output.xml”);

      // Create a tree with a child element.

      XElement xmlTree1 = new XElement(“Root”,

          new XElement(“Child1″, 1)

      );

 

      XElement xmlTreeSub1 = new XElement(“Child1″,

        new XElement(“SubClihd”, 3)

        );

 

      // Create an element that is not parented.

      XElement child2 = new XElement(“Child2″, 2);

 

      // Create a tree and add Child1 and Child2 to it.

      XElement xmlTree2 = new XElement(“Root”,

          xmlTree1.Element(“Child1″),

          xmlTreeSub1,

          child2

      );

 

      // Compare Child1 identity.

      Console.WriteLine(“Child1 was {0}”,

          xmlTree1.Element(“Child1″) == xmlTree2.Element(“Child1″) ?

          “attached” : “cloned”);

 

      // Compare Child2 identity.

      Console.WriteLine(“Child2 was {0}”,

          child2 == xmlTree2.Element(“Child2″) ?

          “attached” : “cloned”);

 

      xmlTree2.WriteTo(xw);

      xw.Flush();

    }

  }

 

You can also download a single solution from http://skydrive.live.com. The sample file name is ConAppXML1.zip My MSN ID is chanmmn@hotmail.com.

Posted in .Net | Tagged , , | Leave a comment

Free ebook: Creating Mobile Apps with Xamarin.Forms, Preview Edition

Download the free book from http://blogs.msdn.com/b/microsoft_press/archive/2014/10/08/free-ebook-creating-mobile-apps-with-xamarin-forms-preview-edition.aspx?loc=zatfz_zTS1z&prod=zWPz&tech=zOtScenz&lang=zCSz_zXMLz&prog=zPressz&type=zBlz&country=zUSz.

Remember, Xamarin is not a free tool even the book is free.

Posted in .Net | Tagged , , , | Leave a comment

7-zip or Winrar

In layman term, I have a folder with 4.76 GB, 19,875 files, and 3,803 folders. Using 7-zip version 9.2 I zipped into 2.2 GB. Using Winrar 5.11 I zipped into 2 GB.

Will I choose 7-zip or Winrar? Well, it depends. 7-zip can edit a file without unzip it somehow I don’t think Winrar has that feature.

Download:

7-zip http://www.7-zip.org/

Winrar http://www.rarlab.com/

Posted in .Net | Tagged , , , | Leave a comment

Bing Map SDK for Windows 8.1 will not work for VS 14 CTP 4

Don’t spend your time if you are thinking to run Bing Map in VS 14 CTP 4 at this moment.

BingWin81 

Posted in .Net | Tagged , | Leave a comment

ASP.NET samples that run in Visual Studio 14 CTP 4

So far I have tried 3 samples. I am running Visual Studio 14 CTP 4 in Windows 10.

1. The Wingtip Toys run without doing anything http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/introduction-and-overview.

2. Bug Tracker you need to change the .NET Framework to 4.5.3 Core. http://blogs.msdn.com/b/webdev/archive/2014/10/06/asp-net-vnext-in-visual-studio-14-ctp-4.aspx.

3. MVC Music Store I am not able to make it work for 1 hour. Maybe you can.  http://blogs.msdn.com/b/webdev/archive/2014/10/06/asp-net-vnext-in-visual-studio-14-ctp-4.aspx

Posted in .Net | Tagged , , , , | Leave a comment

How to resolve when VM in Oracle Virtual Box keep rebooting

If your VM in Virtual Box keep rebooting then there is one thing you can try.

Delete the VM in Virtual Box Manager, DO NOT DELETE THE IMAGE FILE LIKE VDI or VHD. Then add a new VM into Virtual Box Manager with the existing image file. That should work. 

Posted in Community, Computers and Internet, Operating System, Oracle | Tagged , | Leave a comment

The type or namespace name ‘xxxxxx’ could not be found (are you missing a using directive or an assembly reference

There are 3 possibilities

1. You are using .NET Framework 3.5 Client Profile instead of .NET Framework 3.5.

2. You are using .NET Framework 4 Client Profile instead of .NET Framework 4.

3. The .NET Framework uses in your Class Library (dll) is newer than the project refers to it.

Posted in .Net | Tagged , , | Leave a comment