e4x

e4x / as3: How to access a node with a dash in its name

我的未来我决定 提交于 2019-12-01 01:57:58
the e4x implementation in as3 doesn't seem to be able to handle node names that have dashes in them. The musicbrainz api returns xml with a node named artist-list and i can't seem to get it to let me access the node. sample from http://musicbrainz.org/ws/1/artist/?type=xml&name=dr%20dog : <metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#" xmlns:ext="http://musicbrainz.org/ns/ext-1.0#"> <artist-list offset="0" count="1090"> <artist type="Group" id="e9aed5e5-ed35-4244-872e-194862290295" ext:score="100"> </artist> </artist-list> </metadata> If I try to access it like so myXml.artist-list i get

e4x / as3: How to access a node with a dash in its name

丶灬走出姿态 提交于 2019-11-30 22:08:17
问题 the e4x implementation in as3 doesn't seem to be able to handle node names that have dashes in them. The musicbrainz api returns xml with a node named artist-list and i can't seem to get it to let me access the node. sample from http://musicbrainz.org/ws/1/artist/?type=xml&name=dr%20dog : <metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#" xmlns:ext="http://musicbrainz.org/ns/ext-1.0#"> <artist-list offset="0" count="1090"> <artist type="Group" id="e9aed5e5-ed35-4244-872e-194862290295" ext

How to decode HTML entities

牧云@^-^@ 提交于 2019-11-30 09:16:24
I have string variable with HTML entities: var str = 'Some text & text'; I want to convert (decode) it to original characters: Some text & text . JavaScript doesn't have built-in function to achieve wanted result. I can't use jQuery or DOM objects because I need it to work in Google Apps Script. How can I do that in simple way? rik You can use built-in Xml Services: var str = 'Some text & text'; var decode = XmlService.parse('<d>' + str + '</d>'); var strDecoded = decode.getElement().getText(); or you can use built-in E4X XML class. var str = 'Some text & text'; var decode = new XML('<d>' +

How to decode HTML entities

狂风中的少年 提交于 2019-11-29 14:52:12
问题 I have string variable with HTML entities: var str = 'Some text & text'; I want to convert (decode) it to original characters: Some text & text . JavaScript doesn't have built-in function to achieve wanted result. I can't use jQuery or DOM objects because I need it to work in Google Apps Script. How can I do that in simple way? 回答1: You can use built-in Xml Services: var str = 'Some text & text'; var decode = XmlService.parse('<d>' + str + '</d>'); var strDecoded = decode.getElement().getText

E4X: grab nodes with namespaces?

一笑奈何 提交于 2019-11-29 07:58:03
I want to learn how to process XML with namespaces in E4X so basically here is what I want to learn, say I have some XML like this: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"> <rdf:item value="5"/> <item value="10"/> </rdf:RDF> How could I assign <rdf:item/> to a var called rdfItems and <item/> to a var called regItems ? Thanks! I'm not sure whether this answers the question exactly, but given your scenario, the following code retrieves both values (given the "xml" variable, referenced below, is an XML object containing the snippet of XML

Creating a DOM NodeList

妖精的绣舞 提交于 2019-11-29 03:50:37
I'm implementing all of the optional E4X features described in ECMA-357 Annex A and I'm having trouble implementing domNodeList (§A.1.2 and §A.2.2). How would I create my own NodeList object? Even if I create a new XMLDocument and append every domNode() representation of the nodes in an XMLList, I still don't see how I could create a NodeList containing everything as comments and processing instructions are usually excluded. Eli Grey I figured out that I could use the childNodes attribute of a document fragment to create a NodeList. This was my solution: XML.prototype.function::domNodeList =

E4X: grab nodes with namespaces?

只谈情不闲聊 提交于 2019-11-28 01:44:35
问题 I want to learn how to process XML with namespaces in E4X so basically here is what I want to learn, say I have some XML like this: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"> <rdf:item value="5"/> <item value="10"/> </rdf:RDF> How could I assign <rdf:item/> to a var called rdfItems and <item/> to a var called regItems ? Thanks! 回答1: I'm not sure whether this answers the question exactly, but given your scenario, the following code