• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

Formatting XML with XmlTextWriter

I am trying to wrirte XML to a file as text using XmlTextWriter. Everything works fine except the fact that all the empty XML elements in the file are written in the long-hand form:

<info attr1="val"></info>

I would prefer the form

<info attr1="val" />

Is there a way to accomplish this in C#?

Thank you.
1 Solution
There is no setting XmlTestWriter that will help you with this. And for that matter, I don't think there is any thing in Xml namespace that will do it.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now