Hi, i was searching but i didn't find working solution.

I've got xml document and i like to extract part of it and append to
one element in dom tree.

xml:

<elements>
<element>
<id>1</id>
<name>Trusty</name>
<data><tr><td><button>name of button</button></td></tr></data>
</element>
<element>
<id>2</id>
<name>Trusty2</name>
<data><tr><td><button>name of button 2</button></td></tr></data>
</element>
</elements>

and i need to retrieve data betwwen <data> and </data> tags which are
valid html tags - with js etc
BUT
this code is only example and content between data can be diffrent so
i can write one code

before i try jQuery i was using this piece of code to convert this to
html
but it wasn't working corectly if i used script (in
onclick="javaxcript here")


function PrzelecDOM(obiekt) {

        var tmpobiekt;

        if(obiekt.nodeType == 3) {

                tmpobiekt = document.createTextNode(obiekt.nodeValue);

        }

        else {

                tmpobiekt = document.createElement(obiekt.tagName);

        }

        if (isIE) {

                var atrybuty = obiekt.attributes;

                if (atrybuty && atrybuty.length > 0) {

                        for (var a = 0; a < obiekt.attributes.length; a++) {
                                if (obiekt.attributes[a].name == 'class') {
                                        tmpobiekt.setAttribute('className', 
obiekt.attributes[a].value);
                                }
                                else {
                                        
tmpobiekt.setAttribute(obiekt.attributes[a].name,
obiekt.attributes[a].value);
                                }

                        }

                }

        }

        else {



                if (obiekt.hasAttributes()) {

                        var atrybuty = obiekt.attributes;

                        for (var a = 0; a < atrybuty.length; a++) {

                                tmpobiekt.setAttribute(atrybuty[a].name, 
atrybuty[a].value);

                        }

                }

        }

        if (obiekt.hasChildNodes() > 0) {

                var dzieci = obiekt.childNodes;

                for (var a = 0; a < dzieci.length; a++) {

                        tmpobiekt.appendChild(PrzelecDOM(dzieci[a]));

                }

        }

        return tmpobiekt;

}



Maybe somebody will help me with suggestions.
Tahnks in advance

--
Artur

Reply via email to