dimanche 27 novembre 2016

How to get an array of attributes when there is whitespace characters between the name and value?

I'm trying to get an array of attributes and I'm splitting on the whitespace character. What I have works fine except when namespaces are involved. Here is my sample code:

XML:

<?xml version="1.0" encoding="utf-8"?>
<s:node something xmlns:s = "library://ns.adobe.com/flex/spark" 
xmlns:b='testnamespace.com' xmlns="noprefix.com"></something>

Exmascript:

var attributes:Array = tag.split(/\s+/g);

That results in this array of items:

 - something
 - xmlns:s
 - =
 - "library://ns.adobe.com/flex/spark"
 - xmlns:b='testnamespace.com'
 - xmlns="noprefix.com"

How would I split the attributes up when there are spaces between the name and value?

Aucun commentaire:

Enregistrer un commentaire