Access to DOM API methods and properties?

0 favourites
  • 1 posts
From the Asset Store
Integrate Telegram Payments API into your Construct 3 projects for seamless in-app payment processing.
  • While I was writing the message bellow, I resolved the issue. I'll just leave the information here, available to others.

    The Document interface (from where XMLDocument inherit most of its own methods and properties) can already be freely used, but won't show in C3 code suggestion/completion list.

    Greetings!

    First, a bit of context:

    • I'm developing my first Android App and am using an XML as the default database.
    • Information need to persist between sessions. After some research, it seemed convenient to preserve the existing data tree structure by saving it as a XMLDocument using a key in LocalStorage.

    So far I've managed to successfully fetch the XML file from the assets folder, parse it using DOMParser and save it to LocalStorage.

    async function ParseAndSaveXML(runtime){
    	
    	let r, url, xml, parser;
    	
    	try {
    		//Buscar o xml na pasta de assets.
    		url = await runtime.assets.getProjectFileUrl("nutritional_table.xml");
    		r = await fetch(url);
    		xml = await r.text();
    
    		//Transcrever o XML para DOM
    		parser = new DOMParser();
    		tabelaNutricional = parser.parseFromString(xml, "text/xml");
    		
    		console.log(tabelaNutricional.getElementById("water"));
    
    		return;
    		
    	} catch(e) {
    		console.error(e);
    		return e;
    	}
    }

    But now I lack the tools to navigate and edit its nodes.

    I also changed my project's Advanced > Use worker setting to No, as there seems to be a problem with web workers and DOM.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)