I'm trying to parse an XML document (a google calendar feed), but I
have problems when I try to get attributes of a tag with a namespace
(ie: a colon).
Here's my code for this: date = entry.at('gd:when').attributes['startTime']
Instead of having the expected time returned I just get 'nil'.
Anyone know why this is? Or how to get it to work properly?
hpricot isn't quite friendly with namespaces from what I have tried
before (unsure about the current version). Did you tried doing a full
xpath query?
@
···
On Thu, Aug 28, 2008 at 9:40 AM, Mark <markjturner@gmail.com> wrote:
Hi all, I have a question about Hpricot:
I'm trying to parse an XML document (a google calendar feed), but I
have problems when I try to get attributes of a tag with a namespace
(ie: a colon).
Here's my code for this: date =
entry.at('gd:when').attributes['startTime']
Instead of having the expected time returned I just get 'nil'.
Anyone know why this is? Or how to get it to work properly?
On Thu, Aug 28, 2008 at 11:40:33PM +0900, Mark wrote:
I'm trying to parse an XML document (a google calendar feed), but I
have problems when I try to get attributes of a tag with a namespace
(ie: a colon).
Here's my code for this: date =
entry.at('gd:when').attributes['startTime']
Hi Anthony, I haven't I must admit, unfortunately I'm not really
familiar with xpath and I don't know how to find the tag I need with
it, if anybody knows how to do that I'd be very grateful for some
pointers!
Thanks,
Mark
···
On Aug 28, 3:47 pm, Anthony Pearson <a...@serialtactics.com> wrote:
hpricot isn't quite friendly with namespaces from what I have tried
before (unsure about the current version). Did you tried doing a full
xpath query?
@
On Thu, Aug 28, 2008 at 9:40 AM, Mark <markjtur...@gmail.com> wrote:
> Hi all, I have a question about Hpricot:
> I'm trying to parse an XML document (a google calendar feed), but I
> have problems when I try to get attributes of a tag with a namespace
> (ie: a colon).
> Here's my code for this: date =
> entry.at('gd:when').attributes['startTime']
> Instead of having the expected time returned I just get 'nil'.
> Anyone know why this is? Or how to get it to work properly?
Aha, putting the .XML in the Hpricot call seems to have done the
trick, thanks!
And thanks for creating such a useful tool!
···
On Aug 28, 7:18 pm, _why <w...@ruby-lang.org> wrote:
On Thu, Aug 28, 2008 at 11:40:33PM +0900, Mark wrote:
> I'm trying to parse an XML document (a google calendar feed), but I
> have problems when I try to get attributes of a tag with a namespace
> (ie: a colon).
> Here's my code for this: date =
> entry.at('gd:when').attributes['startTime']
Your query is good. I think it must be something else.
On Thu, Aug 28, 2008 at 9:55 AM, Mark <markjturner@gmail.com> wrote:
On Aug 28, 3:47 pm, Anthony Pearson <a...@serialtactics.com> wrote:
hpricot isn't quite friendly with namespaces from what I have tried
before (unsure about the current version). Did you tried doing a full
xpath query?
@
On Thu, Aug 28, 2008 at 9:40 AM, Mark <markjtur...@gmail.com> wrote:
> Hi all, I have a question about Hpricot:
> I'm trying to parse an XML document (a google calendar feed), but I
> have problems when I try to get attributes of a tag with a namespace
> (ie: a colon).
> Here's my code for this: date =
> entry.at('gd:when').attributes['startTime']
> Instead of having the expected time returned I just get 'nil'.
> Anyone know why this is? Or how to get it to work properly?
> Many thanks in advance,
> Mark
Hi Anthony, I haven't I must admit, unfortunately I'm not really
familiar with xpath and I don't know how to find the tag I need with
it, if anybody knows how to do that I'd be very grateful for some
pointers!
Thanks Anthony, unfortunately there are no examples of what I need to
do and it appears the colon has another meaning in xpath queries.
Thanks for the link to the ruby plugin, I'll have to look into that
further.
I'm still very much open to suggestions of how to do it the original
way, however.
···
On Aug 28, 4:45 pm, Anthony Pearson <a...@serialtactics.com> wrote:
Actually google calander has a ruby plugin/api located herehttp://googlecalendar.rubyforge.org/plugins/doc/
If that's not your flavor you can start with hpricot's documentation
on xpaths herehttp://code.whytheluckystiff.net/hpricot/wiki/SupportedXpathExpressions
On Thu, Aug 28, 2008 at 9:55 AM, Mark <markjtur...@gmail.com> wrote:
> On Aug 28, 3:47 pm, Anthony Pearson <a...@serialtactics.com> wrote:
>> hpricot isn't quite friendly with namespaces from what I have tried
>> before (unsure about the current version). Did you tried doing a full
>> xpath query?
>> @
>> On Thu, Aug 28, 2008 at 9:40 AM, Mark <markjtur...@gmail.com> wrote:
>> > Hi all, I have a question about Hpricot:
>> > I'm trying to parse an XML document (a google calendar feed), but I
>> > have problems when I try to get attributes of a tag with a namespace
>> > (ie: a colon).
>> > Here's my code for this: date =
>> > entry.at('gd:when').attributes['startTime']
>> > Instead of having the expected time returned I just get 'nil'.
>> > Anyone know why this is? Or how to get it to work properly?
>> > Many thanks in advance,
>> > Mark
> Hi Anthony, I haven't I must admit, unfortunately I'm not really
> familiar with xpath and I don't know how to find the tag I need with
> it, if anybody knows how to do that I'd be very grateful for some
> pointers!