Hello,
I've spent 2 days trying to figure this out on my own, but I'm starting to think there's a bug in Construct 3's XML plugin, or I'm missing something obscure.
I'm trying to use Construct 3 to create a prototype for a web app I want to build, but I can't seem to get some basic functionality out of the XML plugin that I absolutely need to get this prototype working. I included a project file for debugging purposes, if you think you know what's going on, I would really appreciate some help.
https://drive.google.com/file/d/1IjF4vBzXz3fAqpPodW5qC23PJNQRGFPt/view?usp=sharing
In the project, the user selects an SVG file from their PC and uploads it. For the purpose of debugging, please use 'SVG to import.svg' included in the project files. Just download it and select it from the FileChooser. Once loaded, the SVG object sets its image to the loaded file, AJAX requests the string value of the data and saves it to local storage. A text object is set up to display the values being extracted, easily showing that the correct data is being extracted and saved. Then the user selects to load the data into the XML object from either AJAX.LastData, or LocalStorage.ItemValue.
Either way, the string value should be the same, but this is there to demonstrate that the issue isn't with AJAX or LocalStorage.
Then the user runs one of two XPath expressions to extract a particular value from the SVG file. Both XPath expressions work correctly when used with this website:
https://www.freeformatter.com/xpath-tester.html#before-output
string(//svg/rect[1]/@width) and number(//svg/rect[1]/@width) used with the 'SVG to import.svg' file both result in the value '188', so the expression is correctly working.
The data that the XPath expression is supposed to extract is the 'width' attribute's value for the first 'rect' node. It's an arbitrary request and is just being used for the purpose of demonstrating the problem I'm having, however, the extracted value should be '188'. Instead, the XPath result is either "" or 0.
I've tried several variations of the XPath expression to try and get it to work, but the only differing values I ever got were 'nan' or 'null'.
I tried a lot to get this to work or figure out why it isn't working. I looked in the manual, forums, and education resources for learning how to use XPath expressions. This is my first time messing with XML, and I'm only doing it because .svg files are formatted like XML files, but I did my due diligence to try and figure it out before filling the forums with duplicate questions. I'm linking the other threads I found below, but they really didn't help me much.
https://www.construct.net/en/tutorials/how-to-read-an-xml-and-make-your-game-talk-518
https://www.construct.net/en/tutorials/xml-parsing-209
https://www.construct.net/en/forum/construct-2/how-do-i-18/xpath-70174
https://www.construct.net/en/forum/construct-3/how-do-i-8/xml-twine-like-game-someone-184522