Skip to main content

Bug Tracker

Side navigation

#12126 closed bug (invalid)

Opened July 23, 2012 01:45PM UTC

Closed July 23, 2012 03:07PM UTC

jquery html from xml

Reported by: puchuu Owned by: puchuu
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

http://stackoverflow.com/questions/11609028/jquery-html-from-xml

For dmethvin: do not close issue if you dont understand it. you can contact with me for any extra information

Attachments (0)
Change History (8)

Changed July 23, 2012 01:47PM UTC by puchuu comment:1

_comment0: this is coffee script code that works perfect: \ \ {{{ \ $.ajax \ type: "get" \ url: @options.load_url \ dataType: "xml" \ success: (data) => \ self = this \ scene_sources = [] \ \ self.preload.empty() \ if $.browser.msie \ if $.browser.version == "7.0" or $.browser.version == "8.0" \ self.preload.append $(data.xml).filter(".scene") \ else \ self.preload.append $(data.xml).find(".scene") \ else \ self.preload.append $(data).find(".scene") \ \ html = self.preload.html() \ self.preload.empty().html html \ }}}1343051498961133

this is coffee script code that works perfect:

$.ajax
  type:     "get"
  url:      @options.load_url
  dataType: "xml"
  success: (data) =>
    @preload.empty()
    if $.browser.msie
      if $.browser.version == "7.0" or $.browser.version == "8.0"
        @preload.append $(data.xml).filter(".scene")
      else
        @preload.append $(data.xml).find(".scene")
    else
      @preload.append $(data).find(".scene")

    html = @preload.html()
    @preload.empty().html html

Changed July 23, 2012 01:52PM UTC by dmethvin comment:2

owner: → puchuu
status: newpending

You're right, I have no idea what you are trying to do. You're trying to append XML nodes to an HTML document? Can you provide a clear example in plain JavaScript?

Changed July 23, 2012 01:55PM UTC by puchuu comment:3

status: pendingnew

ok. I will paste link to jsfiddle here in 5-10 minutes

Changed July 23, 2012 02:43PM UTC by puchuu comment:4

Changed July 23, 2012 02:46PM UTC by puchuu comment:5

for dmethvin: I've newer used bugtracker to ask questions. I've posted a workaround on stackoverflow and than created an issue to share my experience with jquery developers

Changed July 23, 2012 02:47PM UTC by dmethvin comment:6

$(data).find("section").html()

You're trying to call .html() on XML nodes. Is that correct? The documentation for .html() is pretty clear it isn't available on XML documents. http://api.jquery.com/html/

I've newer used bugtracker to ask questions.

That is not what a bug tracker is for, so you were correct in using StackOverflow.

Changed July 23, 2012 02:56PM UTC by puchuu comment:7

Replying to [comment:6 dmethvin]:

You're trying to call .html() on XML nodes

I want: get html from xml without using CDATA + .text().

This is possible in theory because this xml is valid html. This is possible with jquery only with workaround that I've posted

Changed July 23, 2012 03:07PM UTC by dmethvin comment:8

resolution: → invalid
status: newclosed

The text ''markup string'' may be valid HTML5, but the in-memory data structures are XML nodes and not HTML nodes. As the documentation says, the .html() method is not available on XML documents. oldIE will not easily import XML nodes into an HTML document. Also, oldIE doesn't support HTML5 so you'll need a shiv/shim which I assume you already have. But none of this is a bug and as far as I can tell things as working as documented.

Perhaps this will help explain the issues:

http://www.alistapart.com/articles/crossbrowserscripting/