PDA

View Full Version : Ext.DomQuery not working with XML namespaces



irvinhg
4 Sep 2012, 1:43 AM
I'm trying to use Ext.DomQuery to query nodes of an XML document of the sort:

xmlDoc:



<?xml version="1.0" encoding="UTF-8"?>
<tns:Definition xmlns:tns="http://definition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://definitionSchema.xsd ">
<tns:Name>MyPodDefSample</tns:Name>
<tns:Version>2013.D0</tns:Version>
<tns:CreationDate>2012-08-22</tns:CreationDate>
<tns:Component>
<tns:Name>Component1</tns:Name>
</tns:Component>
</tns:Definition>





I want to add basic functionality to it, add, delete, replace, etc.. The problem is that in FireFox I can't get Ext.DomQuery to return anything when querying for a node. For example:


Ext.DomQuery.select('Name',xmlDoc.firstChild);

returns an empty array, when in Chrome I can get the node.

Any ideas?

irvinhg
4 Sep 2012, 5:43 AM
I found a solution to my problem, I decided to stick with plain old javascript and use:



var namespace = 'http://definition'
xmlDoc.getElementsByTagNameNS(namespace,'Name');


I haven't tested it with IE but it does the trick with FF and Chrome.