XmlSerializer : formatting tags

manuedit

New Member
I serialize simply Person which has Items as collection using .NET XmlSerializer;\[code\]class Item{ Name Price}class Person{ Name List Items<Item>}\[/code\]Everthing fine...I use XmlWriterSettings to indent my xml file. The output is:\[code\] <?xml version="1.0" encoding="utf-8"?><Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <name>TestName</name> <Items> <Item> <name>one</name> <price>0</price> </Item> <Item> <name>two</name> <price>1</price> </Item> </Items></Viewport>\[/code\]But what I want is :\[code\]<?xml version="1.0" encoding="utf-8"?><Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <name>TestName</name> <Items> <Item name="one" price="0" /> <Item name="two" price="1" /> </Items></Viewport>\[/code\]Shortly instead of \[code\]<Item> <name>one</name> <price>0</price> </Item>\[/code\]I want to write xml as \[code\]<Item name="one" price="0" />\[/code\]How can i do it in .NET(C#) ?
 
Back
Top