The idea is that you store data in an html formatted document instead of XML. In this case data is put in divs and uses the div id to describe the content (eg tmp-title). Then you can do this:

> $("<div></div>")                    ... create a div element
>     .html( htmlString )             ... put your html data into it
>     .find("div#tmp-title")           ... now that we have something jquery can search, look for a div with id=tmp-title
>         .appendTo("#title")        ... and add it to the element in the current document with id=title
>     .end()                               ... drop the div so we can do another search
>     .find("div#tmp-body")         ... and look for the div with id=tmp-body
>         .appendTo("#body")       ... and add it to the element in the current document with id=body
>     .end();                              ... drop that div (this isn't necessary, but keeps the code tidy in case you decide to add more)

A couple of other things:
- I think JQuery can be used directly on XML. Is there any reason you can just put the XML in a global JS variable?
- I've stored XML in a hidden input before, but you have to make sure to encode the string correctly.

Blair

On 9/9/06, Sam Sherlock <[EMAIL PROTECTED]> wrote:
A few weeks ago I asked for information about how to move xml data into a
place holder div in a master document, it was pointed out to me that this
approach would lead to difficulties.  John offered to explain the code below

I would greatly appreciate an explanation and perhaps an example of the code below
> Moving non-HTML elements into an HTML
> document is problematic in most browsers. Another recommendation:
> Instead of returning an XML document, return an HTML one - then you
> can do stuff like this:
>
> $("<div></div>")
>     .html( htmlString )
>     .find("div#tmp-title")
>         .appendTo("#title")
>     .end()
>     .find("div#tmp-body")
>         .appendTo("#body")
>     .end();
>
> Let me know if that makes sense to you, I can try and explain it some more.
>
> --John



much appreciated - Sam

ps Pesky Internet provider cut me off, when they were supposed to be enhancing the service ironic which is why the delay :(


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to