Compare two HTML using C++

Highly accurate C++ diff checker to compare HTML files and find differences between them

Our powerful C++ SDK allows you to find the difference between HTML documents and save the results to a convenient format for viewing. To verify our product capabilities, compare HTML files using this C++ library and see the differences.

View code snippet

Compare HTML in C++

Our C++ SDK is designed to give you the most accurate result, even though comparison is a complex function itself.

Sometimes you need to be sure that the document in the HTML format has not been changed, and if it has, you need to find out what the difference is. Just use our C++ diff tool to compare two HTML files and find differences in whole words or single characters. Moreover, if only one character in a word has changed, this word will be marked as changed entirely.

Now you no longer need to spend time manually comparing HTML documents, and you can quickly find even small changes and export such diffs to a document in a convenient format.

Try to compare HTML documents

Check out how our solution to compare HTML files using C++ SDK works. To achieve this, load the HTML files you want to compare and select the export file format – it will be automatically loaded after comparing.

Note that you need to accept all revisions in compared documents before calling the comparison method, as shown in our example:

Upload the compared file
Run code
Upload the second file to compare
Select the target format from the list
using namespace aspose::words::cloud;

auto config = 
    std::make_shared<ApiConfiguration>(L"####-####-####-####-####", L"##################");
auto wordsApi = std::make_shared<WordsApi>(config);

std::wstring fileName1 = L"Input1.html";
std::wstring fileName2 = L"Input2.html";
std::wstring fileResult = L"Output.html";

//  Upload documents to cloud storage.
auto firstDocumentContent = 
    std::shared_ptr<std::istream>(
	new std::ifstream(std::filesystem::path(fileName1), std::istream::binary));
std::shared_ptr<requests::UploadFileRequest> uploadFirstFileRequest(
    new requests::UploadFileRequest(
        firstDocumentContent, std::make_shared<std::wstring>(fileName1)
    )
);
wordsApi->uploadFile(uploadFirstFileRequest);

auto secondDocumentContent = 
    std::shared_ptr<std::istream>(
	new std::ifstream(std::filesystem::path(fileName2), std::istream::binary));
std::shared_ptr<requests::UploadFileRequest> uploadSecondFileRequest(
    new requests::UploadFileRequest(
        secondDocumentContent, std::make_shared<std::wstring>(fileName2)
    )
);
wordsApi->uploadFile(uploadSecondFileRequest);

//  Compare documents in cloud.
auto compareDataOptions = std::make_shared<aspose::words::cloud::models::CompareData>();
compareDataOptions->setAuthor(std::make_shared<std::wstring>(L"author"));
compareDataOptions->setComparingWithDocument(std::make_shared<std::wstring>(fileName2));
std::shared_ptr<requests::CompareDocumentRequest> compareDocumentRequest(
    new requests::CompareDocumentRequest(
        std::make_shared<std::wstring>(fileName1), 
		compareDataOptions, std::make_shared<std::wstring>(fileResult)
    )
);
wordsApi->compareDocument(compareDocumentRequest);

//  Download result document from cloud storage.
std::shared_ptr<requests::DownloadFileRequest> downloadFileRequest(
    new requests::DownloadFileRequest(
        std::make_shared<std::wstring>(fileResult)
    )
);
auto downloadFileResult = wordsApi->downloadFile(downloadFileRequest);
{
    char buffer[1024];
    std::ofstream fileWriter(fileResult, std::ofstream::binary);
    const auto& fileData = *downloadFileResult->begin();
    while(fileData.second->read(buffer, sizeof(buffer))) {
        fileWriter.write(buffer, sizeof(buffer));
    }
    fileWriter.write(buffer, fileData.second->gcount());
    fileWriter.close();
}
Run code
  
Copy C++ code to the clipboard

How to Compare two text files

  1. Install Aspose.Words Cloud for C++
  2. Add a library reference (import the library) to your C++ project
  3. Load two HTML documents to compare
  4. Call the compareDocument() method to compare HTML docs
  5. Download the result document from the cloud storage

C++ library to use compare

Clone Aspose.Words Cloud SDK for C++ source code from GitHub. You can find detailed information on building and configuring the SDK in the "How to use the SDK" section.

To quickly get the necessary security credentials and access our REST API, please follow these Instructions in the documentation.

System Requirements

Refer to the Repository Documentation to see the details.

Other supported file formats

You can perform compare operation for other file formats:

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2024. All Rights Reserved.