SteMega's Recent Forum Activity

  • You do not have permission to view this post

  • You do not have permission to view this post

  • 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.

  • I'm trying to achieve the same result Quique1222 was a year ago and Ashley's suggestion is the closest thing I've found to a solution.

    The thing is, when I tried to implement the workaround, I couldn't make it work.

    Here's what I did to pinpoint the problem:

    • I was able to consistently save and load the contents of a textbox using System actions.
    • With the save game in place, the result obtained from LocalStorage.KeyCount was 0

    I then created a test key directly with LocalStorage:

    While debugging on Firefox, I used the built-in Storage inspector to determine that they were saved in different folders:

    It can't be done, then?

  • I'm no expert, but I've been messing around with XPath and maybe I can help.

    First of all, text() will just grab contents of a node.

    Therefore "/FreePack/LevelCollection/Level[1]/text()" will try and grab the text contents of the first <Level> node, but there is nothing there to be grabbed!

    (For the following examples, I'll assume that when you said Item, you were referring to <L> nodes.)

    If instead you use "/FreePack/LevelCollection/Level[1]/*/text()" or "/FreePack/LevelCollection/Level[1]/L/text()", you'll grab a sequence of all the contents from each <L> inside the first <Level> node.

    "/FreePack/LevelCollection/Level[1]/L[1]/text()", on the other hand, will get you the contents of a single chosen <L>

  • Greetings!

    First of all, sorry for the bitly-shortened links.

    I'm not able to use any formatting for some reason.

    ---

    Anyway, I'm struggling with the following problem:

    When using XPath's name(nodeset) function to extract the name of a XML element, nothing is retrieved.

    I've done some forum research, but all I found was the following fragments:

    - Ashley stating that Construct merely delegates XPath execution to the browser, having no role in the issue I'm describing ( bit.ly/2Op3JVj ).

    - Magistross running into the issue in Firefox and IE, but not knowing what was wrong ( bit.ly/2Op9CC5 ).

    I decided to test Firefox XPath execution outside of my Construct game using an online tool ( bit.ly/2AWJb4L ) and to my surprise the name() function worked perfectly!

    ---

    Heres's my xml: drive.google.com/open

    My Construct test consisted in printing SpritesXML.StringValue("name(/sprites/*[1])") into a test variable. It's worth mentioning that I successfully loaded the xml into the game using AJAX -> request project file and AJAX -> On complete.

    For the online tool I simply loaded the provided xml using the web interface, then typed name(/sprites/*[1]) as the XPath expression.

    Does anyone know anything else about this?

    Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
SteMega's avatar

SteMega

Member since 29 Mar, 2017

None one is following SteMega yet!

Connect with SteMega

Trophy Case

  • 7-Year Club
  • Email Verified

Progress

8/44
How to earn trophies