Skip to main content

Posts

Showing posts with the label Serialization

Generating XML Root Node having colon - via Serialization

Recently I got a requirement to generate an XML on the fly with some defined schema. I know this requirement looks very simple in first sight, but actually it was not. The XML which was to be generated was having a very specific format as it was supposed to be the input for some 3 rd party tool. So, it means, it should be fully compliant with the prescribed XML node structure. Just have a look at the below schema: <sl:RandomWindow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sl="http://www.ShwetaBlogs.com/Window" xsi:schemaLocation="http://www.ShwetaBlogs.com/Window wwRandomWindow.xsd">   <Title>First Window</Title>   <Border>Single</Border> </sl:RandomWindow> Below are the classes I created for serialization purpose: By using the XmlElement and XmlAttribute classes I was able to generate most of the required parts of the XML as shown below:   But the only th