Re: Formatting XmlTextWriter Output



Tom Jackson wrote:

What I'm running into is where I want to assign both an attribute and content to an element, i.e. to produce

<content encoding="base64binary">encoded content here</content>

it doesn't like it unless I do a "WriteRaw" for the content:

xw.WriteStartElement("content", null);
xw.WriteAttributeString("encoding", "base64binary");
xw.WriteRaw(messageContent);
xw.WriteEndElement(); // end the content element

This comes out fine, but I was just curious if there was another, better, way?

What does "it doesn't like it" mean exactly? Which code exactly have you tried? Which error exactly did you get?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
.


Loading