Re: XML parser under an extension
- From: Giovanni Campagna <scampa giovanni gmail com>
- To: Milan Bouchet-Valat <nalimilan club fr>
- Cc: gnome-shell-list gnome org
- Subject: Re: XML parser under an extension
- Date: Mon, 2 Jan 2012 15:01:57 +0100
On Sun, Jan 1, 2012 at 2:26 PM, Milan Bouchet-Valat <nalimilan club fr> wrote:
> Le dimanche 01 janvier 2012 à 15:47 +0330, bijan binaee a écrit :
>> Hi
>>
>> I'm very sorry about my lot's of question
>>
>> I want know how can i parse XML file and extract element in gnome
>> shell extension
> If the file you want to parse is simple enough, you may be able to use
> GLib's XML parser, which doesn't support the whole XML format. The
> advantage is that you can easily use it from JS like any other GLib
> function. See
> http://developer.gnome.org/glib/stable/glib-Simple-XML-Subset-Parser.html
No you can't, GMarkupParser is not introspectable (you cannot set
structure fields that are function pointers, it would cause leaks or
crashes).
> If you need the full libxml2 features, I'm not sure at all this can be
> done from JS ATM.
But you can use Ecmascript4XML. Just do "new XML(string)", then
traverse the resulting object with obj[elementName][@attribute].
A lot more is possible (like node lists and XPath-like matching), just
check the E4X docs on developer.mozilla.org.
Giovanni
PS: having GMarkup/libxml2 support in gjs would still be useful, since
E4X is available only on SpiderMonkey, so depending massively on it
would impair our ability to switch engine.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]