XML Parsing

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

XML Parsing

Fabian Dittrich
Hi,

i have some question about the Dojo XML Parser:

Lets say i have a .JSP File which outputs something like this:

    output = "<dayview><eightpm type='business'>irgendwas machen</eight><ninepm type='private'>musik hören</nine></dayview>";
    out.println(output);

Now i read this output into a variable using dojo.bind.

What i want to do now is a function which resolves me values form the XML.

I tried out the xml parsers examples but i just couldnt make it.

I need something like a function which returns me the values of the xml.

Like:

valuesforhour = getvaluesforhour("eight");

and that i can get the values out of this object like:


alert(valuesforhour.type);
alert(valuesforhour.content);

Any tipps would be very usefull.

Thanks in Advance



_______________________________________________
Dojo-interest mailing list
[hidden email]
http://dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: XML Parsing

Dylan Schiemann-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fabian,

The thing to keep in mind is that we treat everything as an array, to
normalize attributes and nested elements into a consistent structure.

So with your example:

dojo.debug(frag["eightpm"][0]["eightpm"]["type"][0].value);
// business
dojo.debug(frag["eightpm"][0].value);
// irgendwas machen

assuming you start parsing with dayview as the root node.

We haven't really built in any convenience functions yet as no one has
asked for these before.

Hope that helps,
- -Dylan

Fabian Dittrich wrote:

> Hi,
>
> i have some question about the Dojo XML Parser:
>
> Lets say i have a .JSP File which outputs something like this:
>
>     output = "<dayview><eightpm type='business'>irgendwas
> machen</eight><ninepm type='private'>musik hören</nine></dayview>";
>     out.println(output);
>
> Now i read this output into a variable using dojo.bind.
>
> What i want to do now is a function which resolves me values form the XML.
>
> I tried out the xml parsers examples but i just couldnt make it.
>
> I need something like a function which returns me the values of the xml.
>
> Like:
>
> valuesforhour = getvaluesforhour("eight");
>
> and that i can get the values out of this object like:
>
>
> alert(valuesforhour.type);
> alert(valuesforhour.content);
>
> Any tipps would be very usefull.
>
> Thanks in Advance
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Dojo-interest mailing list
> [hidden email]
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDmzaT8nLgh/JJsxERAk7ZAKCNqNafEtFV9apbrH/AZdnIt+OkVwCfUjyM
DWhz3xi3ZFoq8vWEFdRo+B4=
=Sxeb
-----END PGP SIGNATURE-----
_______________________________________________
Dojo-interest mailing list
[hidden email]
http://dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: XML Parsing

Rk kb
Isn't there a function that accepts a document as an argument: dojo.byId(id, doc)

Dylan Schiemann <[hidden email]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fabian,

The thing to keep in mind is that we treat everything as an array, to
normalize attributes and nested elements into a consistent structure.

So with your example:

dojo.debug(frag["eightpm"][0]["eightpm"]["type"][0].value);
// business
dojo.debug(frag["eightpm"][0].value);
// irgendwas machen

assuming you start parsing with dayview as the root node.

We haven't really built in any convenience functions yet as no one has
asked for these before.

Hope that helps,
- -Dylan

Fabian Dittrich wrote:

> Hi,
>
> i have some question about the Dojo XML Parser:
>
> Lets say i have a .JSP File which outputs something like this:
>
> output = "irgendwas
> machenmusik hören
";
> out.println(output);
>
> Now i read this output into a variable using dojo.bind.
>
> What i want to do now is a function which resolves me values form the XML.
>
> I tried out the xml parsers examples but i just couldnt make it.
>
> I need something like a function which returns me the values of the xml.
>
> Like:
>
> valuesforhour = getvaluesforhour("eight");
>
> and that i can get the values out of this object like:
>
>
> alert(valuesforhour.type);
> alert(valuesforhour.content);
>
> Any tipps would be very usefull.
>
> Thanks in Advance
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Dojo-interest mailing list
> [hidden email]
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDmzaT8nLgh/JJsxERAk7ZAKCNqNafEtFV9apbrH/AZdnIt+OkVwCfUjyM
DWhz3xi3ZFoq8vWEFdRo+B4=
=Sxeb
-----END PGP SIGNATURE-----
_______________________________________________
Dojo-interest mailing list
[hidden email]
http://dojotoolkit.org/mailman/listinfo/dojo-interest


Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping
_______________________________________________
Dojo-interest mailing list
[hidden email]
http://dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Question about dojo.io.bind (XmlHttpRequest), POST, and encoding

Scott J. Miles
dojo.io.bind (really I think, XmlHttpRequest) is sending my data as utf-8
seemingly without regard for any "charset" definition that I supply.
 
Note I am using method: "post" and postContent: myData.

As I mentioned, it doesn't seem to matter what contentType I specify. It
doesn't seem to matter what the charset is for the sending document either.
 
Is this fact documented somewhere? Can I simply rely on XmlHttpRequest
always POSTing utf-8 encoded data or is it dependent on some client
variable?
 
Thanks,
Scott

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 12/9/2005
 

_______________________________________________
Dojo-interest mailing list
[hidden email]
http://dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Question about dojo.io.bind (XmlHttpRequest), POST, and encoding

Bill Keese-2
Hi Scott, I think Bob answered this a month ago, although he says that
the default is ascii.  or are you talking about something different?

> On Nov 28, 2005, at 7:33 PM, David Schontzler wrote:
>
>> Right now you can specify either UTF or ASCII encoding. Encoding gets
>> pretty hairy and we've tried to mimic the browser as much as possible,
>> but I probably missed something. You can try switching between the two
>> by setting encoding on the bind call:
>>
>> dojo.io.bind({
>>  url: "...",
>>  encoding: "utf-8",
>>  ...
>> });
>>
>> That'll give you UTF-8 encoding (the default is ASCII anyhow). If you
>> want to set this option globally, you can do so in djConfig:
>>
>> djConfig = {
>>  bindEncoding: "utf-8",
>>  ...
>> }

Scott J. Miles wrote:

> dojo.io.bind (really I think, XmlHttpRequest) is sending my data as utf-8
> seemingly without regard for any "charset" definition that I supply.
>  
> Note I am using method: "post" and postContent: myData.
>
> As I mentioned, it doesn't seem to matter what contentType I specify. It
> doesn't seem to matter what the charset is for the sending document either.
>  
> Is this fact documented somewhere? Can I simply rely on XmlHttpRequest
> always POSTing utf-8 encoded data or is it dependent on some client
> variable?
>  
> Thanks,
> Scott
>
_______________________________________________
Dojo-interest mailing list
[hidden email]
http://dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

RE: Question about dojo.io.bind (XmlHttpRequest), POST, and encoding

Scott J. Miles
Hi Bill,
 
I believe the "encoding" argument is used for content modes "formNode" and
"content", but not for "postContent". The "postContent" is sent unmodified
as the 'query' content for the XmlHttpRequest.

In this case, the content received by the server seems to be utf-8
regardless of my attempts to affect the encoding. It seems to be something
the browser is choosing, I don’t see any information from the server in the
HTTP headers about server encoding preferences.

Regards,
Scott

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Bill Keese
Sent: Saturday, December 10, 2005 7:12 PM
To: [hidden email]
Subject: Re: [Dojo-interest] Question about dojo.io.bind
(XmlHttpRequest),POST, and encoding

Hi Scott, I think Bob answered this a month ago, although he says that the
default is ascii.  or are you talking about something different?

> On Nov 28, 2005, at 7:33 PM, David Schontzler wrote:
>
>> Right now you can specify either UTF or ASCII encoding. Encoding gets
>> pretty hairy and we've tried to mimic the browser as much as
>> possible, but I probably missed something. You can try switching
>> between the two by setting encoding on the bind call:
>>
>> dojo.io.bind({
>>  url: "...",
>>  encoding: "utf-8",
>>  ...
>> });
>>
>> That'll give you UTF-8 encoding (the default is ASCII anyhow). If you
>> want to set this option globally, you can do so in djConfig:
>>
>> djConfig = {
>>  bindEncoding: "utf-8",
>>  ...
>> }

Scott J. Miles wrote:
> dojo.io.bind (really I think, XmlHttpRequest) is sending my data as
> utf-8 seemingly without regard for any "charset" definition that I supply.
>  
> Note I am using method: "post" and postContent: myData.
>
> As I mentioned, it doesn't seem to matter what contentType I specify.
> It doesn't seem to matter what the charset is for the sending document
either.
>  
> Is this fact documented somewhere? Can I simply rely on XmlHttpRequest
> always POSTing utf-8 encoded data or is it dependent on some client
> variable?
>  
> Thanks,
> Scott
>

 

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 12/9/2005
 

_______________________________________________
Dojo-interest mailing list
[hidden email]
http://dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Question about dojo.io.bind (XmlHttpRequest), POST, and encoding

David Schontzler
In my playing around/testing how XHR gets sent over the wire I found
that it wasn't always the same. It seemed like it was sending UTF-8 to
some servers (my Tomcat server) while just ASCII to others (PHP on
Apache).

Not sure if that helps much, but ya.

-d

On 12/10/05, Scott J. Miles <[hidden email]> wrote:

> Hi Bill,
>
> I believe the "encoding" argument is used for content modes "formNode" and
> "content", but not for "postContent". The "postContent" is sent unmodified
> as the 'query' content for the XmlHttpRequest.
>
> In this case, the content received by the server seems to be utf-8
> regardless of my attempts to affect the encoding. It seems to be something
> the browser is choosing, I don't see any information from the server in the
> HTTP headers about server encoding preferences.
>
> Regards,
> Scott
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Bill Keese
> Sent: Saturday, December 10, 2005 7:12 PM
> To: [hidden email]
> Subject: Re: [Dojo-interest] Question about dojo.io.bind
> (XmlHttpRequest),POST, and encoding
>
> Hi Scott, I think Bob answered this a month ago, although he says that the
> default is ascii.  or are you talking about something different?
>
> > On Nov 28, 2005, at 7:33 PM, David Schontzler wrote:
> >
> >> Right now you can specify either UTF or ASCII encoding. Encoding gets
> >> pretty hairy and we've tried to mimic the browser as much as
> >> possible, but I probably missed something. You can try switching
> >> between the two by setting encoding on the bind call:
> >>
> >> dojo.io.bind({
> >>  url: "...",
> >>  encoding: "utf-8",
> >>  ...
> >> });
> >>
> >> That'll give you UTF-8 encoding (the default is ASCII anyhow). If you
> >> want to set this option globally, you can do so in djConfig:
> >>
> >> djConfig = {
> >>  bindEncoding: "utf-8",
> >>  ...
> >> }
>
> Scott J. Miles wrote:
> > dojo.io.bind (really I think, XmlHttpRequest) is sending my data as
> > utf-8 seemingly without regard for any "charset" definition that I supply.
> >
> > Note I am using method: "post" and postContent: myData.
> >
> > As I mentioned, it doesn't seem to matter what contentType I specify.
> > It doesn't seem to matter what the charset is for the sending document
> either.
> >
> > Is this fact documented somewhere? Can I simply rely on XmlHttpRequest
> > always POSTing utf-8 encoded data or is it dependent on some client
> > variable?
> >
> > Thanks,
> > Scott
> >
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 12/9/2005
>
>
> _______________________________________________
> Dojo-interest mailing list
> [hidden email]
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
_______________________________________________
Dojo-interest mailing list
[hidden email]
http://dojotoolkit.org/mailman/listinfo/dojo-interest