XML declaration and document element on the same line?

P

Phil Knight

When saving XML from an Infopath 2007 form it appears that the XML
declaration and root element are output on the same line. For example, if the
XML file that is opened begins with:

<?xml version="1.0" encoding="utf-8"?>
<Root>

when the form data is saved, the saved file contains:

<?xml version="1.0" encoding="utf-8"?><Root>

I realise that this shouldn't make any difference as far as XML is
concerned, but we are working with a third party application that objects to
the root element appearing on the same line as the XML declaration.

Is there any way we can get InfoPath to insert a new line between the XML
declaration and the document element? And if so, can anyone point me in the
right direction on how to best achieve this?

Would be very grateful for any help.

Regards,
Phil
 
G

Greg Collins

Sorry--you won't see any help from the InfoPath application to
"pretty-print" your XML file. You can look at generating some automation
that pretties up your XML before it goes to the other app. Generating a
generic XSLT for that purpose shouldn't be too difficult. Visual Studio does
that by simply pasting your XML into an XML document.
 
P

Phil Knight

Thanks a lot for the reply. When you say "generating some automation" would
this be something that would be possible to do by way of adding custom code
to the InfoPath save event to override the default save behaviour. I must
admit, I haven't looked at writing code in InfoPath and/or the InfoPath
object model in much detail yet, but if I could do it this way then that
would seem to be the way to go.
 
G

Greg Collins

You "probably" can do this in code--it would have to fix up and replace the
main DOM before save.

Or you could have an interim process outside of InfoPath which applies and
XSL (which you would write) to do the pretty print and save the XML file
back out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top