Retrieve XML data from tree to save to DB

465 views
Skip to first unread message

andreagiorgetta

unread,
Jun 25, 2010, 12:32:20 PM6/25/10
to jsTree
I cannot find any example about the "getXML" function (or posts about
version 1.0rc). Could you provide a brief example of how to use this
function?

Thanks in advance.

Ivan Bozhanov

unread,
Jun 25, 2010, 3:15:10 PM6/25/10
to jstree
Hi, you can find the get_xml function in the xml_data plugin docs
(there you can see the params). As for usage:

$.jstree._focused().get_xml();
or if inside an event handler:
data.inst.get_xml();
or simply:
$("selector-to-tree-container").jstree("get_xml");

But I advise you to use the latest SVN as there were a few bugs with
this function, which were fixed.

Cheers,
Ivan

> You received this message because you are subscribed to the Google Groups "jsTree" group.
> To post to this group, send email to jst...@googlegroups.com.
> To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jstree?hl=en.
>
>

andreagiorgetta

unread,
Jun 25, 2010, 4:54:34 PM6/25/10
to jsTree
Thanks.
I'm using "$("selector-to-tree-container").jstree("get_xml");", it
returns an Object, but it seems to be empty.
If I use

$("selector-to-tree-container").jstree("get_xml").toArray()

the array length is 0.

I get the same result if I call $("selector-to-tree-
container").jstree("get_xml") before modifying tree data or after
that.

Original XML data for my tree is:

<?xml version="1.0" encoding="UTF-8"?><root> <item id="raiz"
rel="root"> <content><name><![CDATA[Raiz]]></name></content> </item>
<item id="1" parent_id="raiz" rel="category"> <content><name><!
[CDATA[Categoria 1]]></name></content> </item> <item id="2"
productID="1" parent_id="1"> <content><name><![CDATA[Producto 1]]></
name></content> </item> <item id="3" productID="2" parent_id="1">
<content><name><![CDATA[Producto 2]]></name></content> </item> <item
id="4" parent_id="raiz" rel="category"> <content><name><!
[CDATA[Categoria 2]]></name></content> </item> <item id="5"
parent_id="4"> <content><name><![CDATA[Producto 3]]></name></content>
</item></root>


How do I read "get_xml" result?
Thanks in advance.
Andrea.
> > For more options, visit this group athttp://groups.google.com/group/jstree?hl=en.- Hide quoted text -
>
> - Show quoted text -

vakata

unread,
Jun 26, 2010, 4:48:34 PM6/26/10
to jsTree
Try using the latest commit from the SVN. Also make sure the selector
is correct - it will return an emty object if the selector you
supplied is not correct - try $("#id-of-tree-container") or just the
same selector you used to construct the tree.

Cheers,
Ivan
> > > For more options, visit this group athttp://groups.google.com/group/jstree?hl=en.-Hide quoted text -
>
> > - Show quoted text -- Скриване на цитирания текст -
>
> - Показване на цитирания текст -

andreagiorgetta

unread,
Jun 28, 2010, 9:07:57 AM6/28/10
to jsTree
Grrr! you're right... I was using $("tree") instead of $("#tree")

Thanks!


On Jun 26, 5:48 pm, vakata <ivan.bozha...@gmail.com> wrote:
> Try using the latest commit from the SVN. Also make sure the selector
> is correct - it will return an emty object if the selector you
> supplied is not correct - try $("#id-of-tree-container") or just the
> same selector you used to construct the tree.
>
> Cheers,
> Ivan
>
> > > > For more options, visit this group athttp://groups.google.com/group/jstree?hl=en.-Hidequoted text -
>
> > > - Show quoted text -- Ñêðèâàíå íà öèòèðàíèÿ òåêñò -
>
> > - Ïîêàçâàíå íà öèòèðàíèÿ òåêñò -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages