Skip to main content

Bug Tracker

Side navigation

#3811 closed bug (invalid)

Opened January 08, 2009 02:22PM UTC

Closed January 11, 2009 04:04AM UTC

Last modified March 14, 2012 11:04PM UTC

jQuery doesn't create proper case-sensitive XML elements

Reported by: SineSwiper Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: XML uppercase create Cc:
Blocked by: Blocking:
Description

When creating new elements with the core method, jQuery will only create UPPERCASE tags. Specifying the XML ownerDocument doesn't help. Using append with a on-the-fly element won't create it, either.

For example:

xml = xmlDoc();  // method varies on browsers
root = xml.documentElement;  // contains first root tag

el = $('<xml_el>');  // creates "<XML_EL/>"
el = $('<xml_el/>');  // same problem
el = $('<xml_el></xml_el>');  // same problem

el = $('<xml_el>', xml);  // returns an empty set
el = $('<xml_el>', root);  // also returns an empty set

el = $(xml.createElement('xml_el'))  // this works, but is kinda cumbersome

subEl = el.append('<xml_qqq>');   // doesn't work
subEl = el.append('<xml_qqq/>');  // doesn't work
subEl = el.append('<xml_qqq>42</xml_qqq>');  // doesn't work

This was tested on Firefox 3.0.5, though I haven't tried IE yet. (I always assume IE is just going to be worse, anyway...)

Attachments (1)
  • xml.js (2.5 KB) - added by SineSwiper January 12, 2009 06:23PM UTC.

    Example XML code

Change History (2)

Changed January 11, 2009 04:04AM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

jQuery doesn't have an XML parser. You're using its HTML parser. The strings passed in there are sent to a div's .innerHTML to parse them. See this thread:

http://markmail.org/message/i2kytvrcn7cvdegn

Changed January 12, 2009 06:18PM UTC by SineSwiper comment:2

Okay, maybe I'm asking more for an enhancement. Just about everything else in jQuery works for XML: searching for tags in the tree, grabbing text within a tag, setting attributes. The only things not in jQuery is a proper way to create an XML document, serialization (to strings), and creating a tag. I thinking this could be achieved without the need for a plug-in, especially considering that XML parsing is already available in $.ajax, and the creation of XML trees for POST submission is very much an AJAX function.

I can attach some example code to be adapted for the missing pieces.