How to Set the Language Code of an HTML Document in C# .NET Framework
Did you know that setting the language code of an HTML document assists search engines and browsers in locating the appropriate site for a user? In this brief tutorial, we will demonstrate how you can set the language code of an HTML document by using an API in C#, enabling you to get the most out of your HTML.
We will begin by running this command to install the SDK:
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.4.2
Next, we will input our file or file URL, preferred language code, and API key into the below 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 EditHtmlHtmlSetLanguageExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");var apiInstance = new EditHtmlApi();
var languageCode = languageCode_example; // string | The HTML langauge code to set.
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
{
// Sets the language for the HTML document
byte[] result = apiInstance.EditHtmlHtmlSetLanguage(languageCode, inputFile, inputFileUrl);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling EditHtmlApi.EditHtmlHtmlSetLanguage: " + e.Message );
}
}
}
}
By the end of this simple operation, the language will be set! If you need to obtain an API key, you can do so by registering for a free account on the Cloudmersive website; this provides 800 monthly calls across any of our APIs.