Merge XML via C++

Merge XML documents. Use Aspose.PDF for C++ to modify XML files programmatically

Merge XML files Using C++

In order to merge XML file, we’ll use Aspose.PDF for C++ API which is a feature-rich, powerful, and easy-to-use document manipulation API for cpp platform. A peculiar feature of Aspose.PDF is an API for combining XML. The trait of this approach is that you only need to open the NuGet, search for Aspose.PDF, and install it without any special complex settings. Our C++ Library can convert a document from any supported download format to any supported save format. Aspose.PDF for C++ library provides fairly universal solutions that will help you solve the tasks of converting documents. Aspose.PDF supports the largest number of popular document formats, both for loading and saving. Draw your attention that the current section describes only popular conversions. The current page provides information about converting format to format. However, there are many combinations for converting your files. For a complete list of supported formats, see the section Supported File Formats. Check the details of Installing the Library on the Documentation pages. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

How to Merge XML files via C++


You need Aspose.PDF for C++ to try the code in your environment.

  1. Open first document.
  2. Open second document.
  3. Add pages of second document to the first.
  4. Save concatenated output file

C++ - example code to merge XML file

Input file:

File not added

File not added

Output format:

Output file:

    String _dataDir("C:\\Samples\\Conversion\\");
    String infilenameXSL("c:\\samples\\employees.xslt");
    String infilenameXML("c:\\samples\\employees.xml");

    String outfilename("XMLFOtoPDF.pdf");

    // Instantiate XslFoLoadOption object
    auto options = new XslFoLoadOptions(infilenameXSL);
    // Set error handling strategy
    options->ParsingErrorsHandlingType = XslFoLoadOptions::ParsingErrorsHandlingTypes::ThrowExceptionImmediately;
    // Create Document object
    auto document1 = MakeObject<Document>(infilenameXML, options);
    auto document2 = MakeObject<Document>(infilenameXML, options);

    // Add pages of second document to the first
    document1->get_Pages()->Add(document2->get_Pages());

    // Save concatenated output file
    document1->Save(_dataDir+outputFileName);