473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Any way to get node list by giving tagnames without prefixes

I need to parse various XMLs in my application. It has a generic
template structure but the prefixes with the same tagname may be
inconsistent... so I cannot give prefix in
getElementsByTagName(<tagname>).. (Am using DOM parser).. I've tried
getElementsByTagName("*",<tagname>) but that too didn't work... is
there any way I can fetch the nodelist
Thanks in advance

Oct 4 '05 #1
4 1209
Sorry for typo .. the second method refers
getElementsByTagNameNS("*",<tagname>)

Oct 4 '05 #2

ev*********@gmail.com wrote:
Sorry for typo .. the second method refers
getElementsByTagNameNS("*",<tagname>)


The prefix does not matter, the namespace URI is what matters, and the
local name, see
<http://www.w3.org/TR/DOM-Level-2-Core/core.html#i-Document>
so all you need to know is the namespace URI of the elements you are
looking for (e.g. http://www.w3.org/1999/xhtml for XHTML elements) and
the local name (e.g. p for paragraph elements) then
document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p")
will give you all XHTML <p> elements, whether they are written as
<p xmlns="http://www.w3.org/1999/xhtml">
or
<pf1:p xmlns:pf1="http://www.w3.org/1999/xhtml">
in the markup does not matter.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 4 '05 #3
Thanks Martin.. but i do not know the namespace uri in advance. So I
tried with the special value "*" to fetch nodes with name p belonging
to any uri as said in the documentation. But that too didn't work..:( ..

Oct 5 '05 #4


ev*********@gmail.com wrote:
but i do not know the namespace uri in advance. So I
tried with the special value "*" to fetch nodes with name p belonging
to any uri as said in the documentation. But that too didn't work..:( ..


Please provide a short sample XML that you are trying to parse, and then
tell us details about which DOM API/parser and which programming
language you use to do that.
Post the relevant snippet of code that tries to access the elements and
tell us exactly what happens, "didn't work" is not specific enough, did
you get a node list with a length of 0, or did you get any error, which
error exactly?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 5 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: connah | last post by:
Hi All! How can I obtain the full XML path of any given XML Node? For example, if my XML document looks like this: ---BEGIN XML DOC--- <Tag1> <Tag2> <Tag3></Tag3> </Tag2>
1
by: lg2530 | last post by:
template<class T> struct NODE { T data; NODE<T> * next; }; template<typename T> NODE<T>* QuickSortList( NODE<T>* list ) {}
4
by: Dropkick Punt | last post by:
Hi. I have a list of common prefixes: And I have a string, that I split() into a list. Now I want to strip the sentence of all words in the prefix list. I tried this method:
10
by: Aditya | last post by:
Hi All, I would like to know how it is possible to insert a node in a linked list without using a temp_pointer. If the element is the first element then there is no problem but if it is in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.