[jQuery] How to get the TagName of a jQuery object?
Hello, let's say i have an xml (or html or whatever) of this sort:
<pages>
<page>
<title>first</title>
<content>lorem ipsum</content>
</page>
<page>
<title>second</title>
<content>lorem ipsum</content>
<something>other</something>
</page>
....
</pages>
and i want to iterate over the tags within each page and transform
them into
<page>
<data name="title">first</data>
<data name="content">lorem</data>
</page>
...
i've figured out a way of doing it by providing an initial array and
using that as selectors, for example
tagsArray=new Array("title","content","something")
$("page").each(
for (i in tagsArray){
var tagText=$(tagsArray[i],this).text();
//etc
data+='<data name="'+tagsArray[i]+'">'+tagText+'</data>';
//etc
}
)
---The question is, how do i make tagsArray independent from the xml?
e.g. if the xml is not <title> <content> <something>? i need to find $
('*').not('page').not('pages') and transform this into an array of
tagNames. How??
thanks!