How to Retrieve the Sitemap URL for an HTML Document in C# .NET Framework
The sitemap URL can be a particularly helpful tool, especially when you’re trying to increase the rank of your web page. In this brief tutorial, we’re going to show you a solution that will automatically retrieve the sitemap link URL for an HTML document in C#.
Our first step is to install the SDK:
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.4.2
Then, we will simply input the file or file URL into the following example code:
using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example
{
public class EditHtmlHtmlGetSitemapExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");var apiInstance = new EditHtmlApi();
var inputFile = new System.IO.FileStream("C:\\temp\\inputfile", System.IO.FileMode.Open); // System.IO.Stream | Optional: Input file to perform the operation on. (optional)
var inputFileUrl = inputFileUrl_example; // string | Optional: URL of a file to operate on as input. (optional)try
{
// Gets the sitemap URL for the HTML document
HtmlGetSitemapUrlResult result = apiInstance.EditHtmlHtmlGetSitemap(inputFile, inputFileUrl);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling EditHtmlApi.EditHtmlHtmlGetSitemap: " + e.Message );
}
}
}
}
And without any further ado, the sitemap link will be returned! If you need to retrieve an API key, you can do so by registering for a free account on the Cloudmersive website; this will provide you with 800 calls/month across our multitude of APIs.