Get HTML fragments using XPath

Introduction

This article explain how to get the HTML fragments from the HTML document that match the specified XPath query. Aspose.HTML Cloud provide two APIs to get the list of HTML fragments:

API Information

API Type Description Swagger Link
/html/{name}/fragments/{outFormat} GET Return list of HTML fragments matching the specified XPath query GetDocumentFragmentByXPath
/html/fragments/{outFormat} GET Return list of HTML fragments matching the specified XPath query by the source page URL GetDocumentFragmentByXPathByUrl

cURL Example

Available SDKs

Using an SDK (API client) is the quickest way for a developer to speed up the development. An SDK takes care of a lot of low-level details of making requests and handling responses and lets you focus on writing code specific to your particular project. Checkout our GitHub repository for a complete list of Aspose.HTML SDKs along with working examples, to get you started in no time. Please check Available SDKs article to learn how to add an SDK to your project.

SDK Examples

Case 1: Get list of HTML fragments matching the specified XPath query:

Case 2: Get list of HTML fragments matching the specified XPath query by the source page URL: