I have an C# class that I would like to serialize using XMLSerializer. But I would like to have it serialized to a XMLElement or XMLDocument. Is this possible or do I have to serialize it to a String and then parse the string back to a XMLDocument?
1. Statutory conversion is a relatively new, streamlined procedure, available in many states, that allows you to convert your corporation to an LLC by filing a few forms with the secretary of state's office. Each state that permits statutory conversions has its own specific forms and rules.
After conversion from a C corp, an S corporation can inherit income such as rent, interest, retained earnings, funds derived from stock sales, etc. Passive income that makes up more than 25% of an S corp's gross income is subject to tax.
If your C corporation is eligible for S corporation status, you need to complete IRS Form 2553, Election By a Small Business Corporation. The form needs to be signed and dated by a corporate officer with the authority to sign on the corporation's behalf.
Steps to Convert a C Corporation to an S Corporation All shareholders must sign the form. The timeframe for submitting the form can be no later than two months and 15 days from the beginning of the tax year. This will be the tax year when the S corp election is made.
I had this problem too, and Matt Davis provided a great solution. Just posting some code snippets, since there are a few more details.
public static XmlElement SerializeToXmlElement(object o)
{
XmlDocument doc = new XmlDocument();
using(XmlWriter writer = doc.CreateNavigator().AppendChild())
{
new XmlSerializer(o.GetType()).Serialize(writer, o);
}
return doc.DocumentElement;
}
public static T DeserializeFromXmlElement<T>(XmlElement element)
{
var serializer = new XmlSerializer(typeof(T));
return (T)serializer.Deserialize(new XmlNodeReader(element));
}
You can create a new XmlDocument, then call CreateNavigator().AppendChild(). This will give you an XmlWriter you can pass to the Serialize method that will dump into the doc root.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With