Dart
Dart
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 Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// Note: This example requires the Chilkat Bundle license.
// Any string argument automatically begins the 30-day trial.
final glob = CkGlobal();
try {
glob.unlockBundle('30-day trial');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final http = CkHttp();
var html = '';
try {
html = http.quickGetStr('http://www.intel.com/');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final htmlToXml = CkHtmlToXml();
// Indicate the charset of the output XML we'll want.
htmlToXml.xmlCharset = 'utf-8';
// Set the HTML:
htmlToXml.html = html;
// Convert to XML:
final 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');
print('Finished.');
}