Read StringValue XML on IE (Bug+Fix)

Bugs will be moved here once resolved.

Post » Tue May 05, 2015 1:28 pm

Problem Description
"StringValue" Method of "XML" plugin doesn't work properly on IE.
In the runtime.js of xml plugin (row 270) actually Construct use this method
Code: Select all
                  
         if (!result)
            ret.set_string("");
         else if (this.runtime.isIE)
            ret.set_string(result.nodeValue || "");
         else
            ret.set_string(result.stringValue || "");

But The nodeValue property of XML elements is always null, because the element content is actually stored within text nodes inside the element. If the content is simple enough, you can do something like result.firstChild.nodeValue but i personally prefer the nodeTypedValue method.
Actually, I've modified the code as
Code: Select all
         if (!result)
            ret.set_string("");
         else if (this.runtime.isIE)
            ret.set_string(result.nodeTypedValue || ""); //Workaround by RisingPixel
         else
            ret.set_string(result.stringValue || "");

And it works!

Attach a Capx
I can't upload my full project at this moment, but i can attach a screenshot of the debugger's precise line http://imgur.com/8aCx4Er
If you need, I can make a custom .capx later

Steps to Reproduce Bug
  • Create a multi-level XML with some text and number value
  • Use XMLPlugin.StringValue('/yournode/yourchildnode") in a console.log or in a textbox

Observed Result
Returns nothing...

Expected Result
Returns some text

Affected Browsers
  • Chrome: (NO)
  • FireFox: (NO)
  • Internet Explorer: (YES)

Operating System and Service Pack
Windows 8.1 with Internet Explorer 11

Construct 2 Version ID
Construct R200 64bit with Business license
Luca ConTato [RisingPixel]
Image
B
22
S
8
G
2
Posts: 112
Reputation: 2,899

Post » Tue May 05, 2015 1:43 pm

In the meantime, you can append text() to your xpath and force it to select the text node.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Thu May 14, 2015 1:49 pm

Thanks, fixed for next build.
Scirra Founder
B
397
S
236
G
88
Posts: 24,408
Reputation: 194,496


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests