Using namespaces on 2012 platform

Published 2014-10-27 | (Compatible with SDK 3.5,4.5,5.0,5.1 and 2012,2013,2014 models)

New methods on 2012 platform for getting XML elements and attributes created within namespaces.

To avoid conflict in same name tags in XML & smooth parsing, namespace is used. It is defined by 'xmlns' attribute in start tag of an element with syntax as xmlns:prefix= "URI". getAttribute & getElementByTagName, work fine on Maple but causes error on webkit.

Source Files


The files needed for the sample application are here.


Replace getElementByTagName with getElementsByTagNameNS, getAttribute with getAttributeNS and prefix with actual URI.

Bad example

var tServiceID = itemList[itemIdx].getElementsByTagName("secapi:widget")[0].getAttribute("id");
itemID = itemList[itemIdx].getAttribute("secapi:chid");

Good example

var tServiceID = itemList[itemIdx].getElementsByTagNameNS("",
itemID = itemList[itemIdx].getAttributeNS("", "chid") ;