Sample code for 30+ languages & platforms
React Native

Load XML from a Remote URL

Demonstrates how to load XML from a remote URL, such as https://www.chilkatsoft.com/hamlet.xml

Chilkat React Native Downloads

React Native
import { Http, StringBuilder, Xml } from '@chilkat/react-native'

async function chilkatExample() {
  // This example assumes the Chilkat HTTP API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  const http = new Http();
  const sbXml = new StringBuilder();

  // Download the XML from the URL into sbXml
  try {
    await http.quickGetSbAsync('https://www.chilkatsoft.com/hamlet.xml', sbXml);
  } catch {
    console.log(http.lastErrorText);
    return;
  }

  const xml = new Xml();

  // Load the XML contained in sbXml
  try {
    xml.loadSb(sbXml, true);
  } catch {
    console.log(xml.lastErrorText);
    return;
  }

  console.log('Success.');
}