Concatenate xml files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sham

    #1

    Concatenate xml files

    Hi to all,

    Is it possible with the .net framework to concatenate xml files?

    I have a number of xml files on disk and want to create one file which will
    have the format :

    <files>
    <file filename="a.xml " directory="c:\d ata\">
    xml contents of file a.xml go here
    </file>
    <file filename="b.xml " directory="c:\d ata\">
    xml contents of file a.xml go here
    </file>
    ...
    </files>

    Sham


  • Martin Honnen

    #2
    Re: Concatenate xml files



    sham wrote:

    [color=blue]
    > Is it possible with the .net framework to concatenate xml files?
    >
    > I have a number of xml files on disk and want to create one file which will
    > have the format :
    >
    > <files>
    > <file filename="a.xml " directory="c:\d ata\">
    > xml contents of file a.xml go here
    > </file>
    > <file filename="b.xml " directory="c:\d ata\">
    > xml contents of file a.xml go here
    > </file>
    > ...
    > </files>[/color]

    What you want to do there is not possible in general, imagine any of
    those XML documents has an XML declaration and/or a !DOCTYPE
    declaration, if you simply copied the complete XML markup inside of
    <file>
    </file>
    then the result is not well-formed.
    So you need to be more specific on what exactly you want to copy
    (perhaps the root element?), then it is certainly possible to use
    various .NET tools like XmlReader/Writer or XSLT to construct your
    result document.



    --

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

    Comment

    Working...