Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1071943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:46:55+00:00 2026-05-16T20:46:55+00:00

This subject has been touched on before, but there’s been some time since the

  • 0

This subject has been touched on before, but there’s been some time since the last question regarding namespace handling.

Is there a cross-browser solution to get the elements by name in Javascript?

<?xml version="1.0" encoding="UTF-8"?>
<NS:response success="1" xmlns:NS="http://someURI/ns">
   <NS:user firstname="foo" lastname="bar"></NS:user>
   <NS:cookie value="2c0ea35bcac2e05d439609367a236b28" name="session"></NS:cookie>
</NS:response>

So far what I’ve got:

var oXML = (new DOMParser()).parseFromString(xmlstring, "text/xml");
var root = oXML.documentElement;
var user = typeof(user=root.getElementsByTagName(root.prefix + ':user')[0]) === "undefined"
              ?root.getElementsByTagName('user')[0]
              :user;

Hasn’t been tested in IE, but if anyone has any cross-browser solution, I’d be willing to hear.

Other Considerations:

  • getElementsByTagNameNS() – am trying to avoid having to specify the namespace/uri
  • using regex to strip the namespace before creating the XML document
  • not using a namespace – I have that option, but would not like to go that route
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:46:56+00:00Added an answer on May 16, 2026 at 8:46 pm

    You could try another approach, by converting the XML to JSON server side, using a generic XSLT like http://code.google.com/p/xml2json-xslt/, and deliver to the browser only JSON.

    It will add up a small overhead on the server response, but nothing compared to the amount of code and time spent on the browser to render XML.

    With the exception of IE, with its impressive msxml, I think reading XML in common browsers is a real pain compared to JSON.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this subject has been covered before on here but I need a
I know this question has been asked in several variations before, but my question
I know this subject has been discussed before but still have problem with refresh
This question has been the subject of some lively discussions in my team. My
I know this subject has been beaten to death but after searching for a
I know this has probably been answered before, but I cannot find much information
I know this question has been asked many times, but I am having trouble
I know this subject has been done already over and over. but... i must
I'm sorry if this subject has already been answered, but I couldn't find what
First, I know this question has been asked several times before and that in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.