React Native
React Native
Download HTML from URL and Convert to XML
See more HTML-to-XML/Text Examples
Downloads an HTML page from a URL and converts it to XML.Chilkat React Native Downloads
import { Global, HtmlToXml, Http } from '@chilkat/react-native'
async function chilkatExample() {
// Note: This example requires the Chilkat Bundle license.
// Any string argument automatically begins the 30-day trial.
const glob = new Global();
try {
glob.unlockBundle('30-day trial');
} catch {
console.log(glob.lastErrorText);
return;
}
const http = new Http();
let html = '';
try {
html = await http.quickGetStrAsync('http://www.intel.com/');
} catch {
console.log(http.lastErrorText);
return;
}
const htmlToXml = new HtmlToXml();
// Indicate the charset of the output XML we'll want.
htmlToXml.xmlCharset = 'utf-8';
// Set the HTML:
htmlToXml.html = html;
// Convert to XML:
const xml = htmlToXml.toXml();
// Save the XML to a file.
// Make sure your charset here matches the charset
// used for the XmlCharset property.
htmlToXml.writeStringToFile(xml, 'qa_output/out.xml', 'utf-8');
console.log('Finished.');
}