W3C xml get element with namespace and without namespace -
i have xml below,
<?xml version="1.0" encoding="utf-8" standalone="no" ?> <entities xmlns="sample"> <entity> sample value </entity> <ns1:entity xmlns:ns1="sample"> sample value </ns1:entity> </entities> when use nodeelement.getnodename();, can able <entity> not <ns1:entity>.
verified this post , tried getlocalname() instead of getnodename(). not working. when tried using getelementbytagnamens("entity","sample"), getlength() method returned 0.
updated:
as mentioned in below answer interchanged parameters of getelementbytagnamens. see option use getelementbytagnamens("*","entity") allows me not hardcode namespace in code. wanted know, there disadvantage of using *.
getelementbytagnamens("entity","sample") should getelementsbytagnamens("sample","entity"), i.e. namespace name comes before local name.
you may have made similar mistake when trying nodeelement.getnodename() haven't posted relevant code.
Comments
Post a Comment