Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IXMLDOMDocument::Save() with line breaks and indenting?

476 views
Skip to first unread message

Cartoper

unread,
Jun 28, 2008, 11:30:20 PM6/28/08
to
How do you use MSXML2::IXMLDOMDocument::save() to include line breaks
and indents?

Martin Honnen

unread,
Jun 29, 2008, 7:20:45 AM6/29/08
to
Cartoper wrote:
> How do you use MSXML2::IXMLDOMDocument::save() to include line breaks
> and indents?

I don't think you can get the save method to indent. What you can do
however is run an XSLT transformation to create an indentend document,
then save that.
The XSLT stylesheet to do that is as easy as

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

Apply that with transformNodeToObject to transform the DOM document you
have to a new DOM document, then call the save method on the result.


--

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

Sam Hobbs

unread,
Jul 2, 2008, 6:50:58 AM7/2/08
to
A few months ago I asked a similar question and got a similar answer. I
don't remember if there was more information in that thread but I know
someone suggested use of a separate utility to reformat XML.


"Cartoper" <cart...@gmail.com> wrote in message
news:ad25479e-b601-46a2...@y38g2000hsy.googlegroups.com...

borisbovduy

unread,
Oct 21, 2009, 10:09:07 AM10/21/09
to
Hello!

I had same problem with IXMLDOMDocument. It saves xml in huge line.
I found sample that it creates and saves xml document correctly with line breaks and indents.
http://msdn.microsoft.com/en-us/library/ms766497(VS.85).aspx
I used this code and that solved my problem.

Hope, it will helpful for you.

Cartoper wrote:

IXMLDOMDocument::Save() with line breaks and indenting?
30-???-08

How do you use MSXML2::IXMLDOMDocument::save() to include line breaks
and indents?

Previous Posts In This Thread:

On 29 ???? 2008 ?. 7:20
Martin Honnen wrote:

Re: IXMLDOMDocument::Save() with line breaks and indenting?
Cartoper wrote:

I do not think you can get the save method to indent. What you can do


however is run an XSLT transformation to create an indentend document,
then save that.
The XSLT stylesheet to do

On 30 ???? 2008 ?. 20:31
Cartoper wrote:

IXMLDOMDocument::Save() with line breaks and indenting?


How do you use MSXML2::IXMLDOMDocument::save() to include line breaks
and indents?

On 2 ???? 2008 ?. 6:50
Sam Hobbs wrote:

A few months ago I asked a similar question and got a similar answer.
A few months ago I asked a similar question and got a similar answer. I

do not remember if there was more information in that thread but I know


someone suggested use of a separate utility to reformat

EggHeadCafe - Software Developer Portal of Choice
How To Create a Custom IE8 Accelerator
http://www.eggheadcafe.com/tutorials/aspnet/8ae07577-f1c5-498b-a7da-11c3e7cc2a61/how-to-create-a-custom-ie.aspx

0 new messages