Last change
on this file since 29852 was 29852, checked in by Georgiy Litvinov, 9 years ago |
Ckeditor integration commit
|
File size:
1.3 KB
|
Rev | Line | |
---|
[29852] | 1 | /**
|
---|
| 2 | * jQuery xml plugin
|
---|
| 3 | * Converts XML node(s) to string
|
---|
| 4 | *
|
---|
| 5 | * Copyright (c) 2009 Radim Svoboda
|
---|
| 6 | * Dual licensed under the MIT (MIT-LICENSE.txt)
|
---|
| 7 | * and GPL (GPL-LICENSE.txt) licenses.
|
---|
| 8 | *
|
---|
| 9 | * @author Radim Svoboda, user Zzzzzz
|
---|
| 10 | * @version 1.0.0
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | * Converts XML node(s) to string using web-browser features.
|
---|
| 16 | * Similar to .html() with HTML nodes
|
---|
| 17 | * This method is READ-ONLY.
|
---|
| 18 | *
|
---|
| 19 | * @param all set to TRUE (1,"all",etc.) process all elements,
|
---|
| 20 | * otherwise process content of the first matched element
|
---|
| 21 | *
|
---|
| 22 | * @return string obtained from XML node(s)
|
---|
| 23 | */
|
---|
| 24 | jQuery.fn.xml = function(all) {
|
---|
| 25 |
|
---|
| 26 | //result to return
|
---|
| 27 | var s = "";
|
---|
| 28 |
|
---|
| 29 | //Anything to process ?
|
---|
| 30 | if( this.length )
|
---|
| 31 |
|
---|
| 32 | //"object" with nodes to convert to string
|
---|
| 33 | (
|
---|
| 34 | ( ( typeof all != 'undefined' ) && all ) ?
|
---|
| 35 | //all the nodes
|
---|
| 36 | this
|
---|
| 37 | :
|
---|
| 38 | //content of the first matched element
|
---|
| 39 | jQuery(this[0]).contents()
|
---|
| 40 | )
|
---|
| 41 | //convert node(s) to string
|
---|
| 42 | .each(function(){
|
---|
| 43 | s += window.ActiveXObject ?//== IE browser ?
|
---|
| 44 | //for IE
|
---|
| 45 | this.xml
|
---|
| 46 | :
|
---|
| 47 | //for other browsers
|
---|
| 48 | (new XMLSerializer()).serializeToString(this)
|
---|
| 49 | ;
|
---|
| 50 | });
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | return s;
|
---|
| 54 |
|
---|
| 55 | };
|
---|
| 56 | |
---|
Note:
See
TracBrowser
for help on using the repository browser.