Mojo::Dom Mojo::CSS3 and XML

57 views
Skip to first unread message

marcos rebelo

unread,
Jun 18, 2012, 4:35:51 PM6/18/12
to mojol...@googlegroups.com
Hi all

I have a file with the content:

<?xml version="1.0" encoding="utf-8" standalone="yes"?><manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"><manifest:file-entry manifest:full-path="/" manifest:media-type="application/vnd.oasis.opendocument.text" /><manifest:file-entry manifest:full-path="content.xml" manifest:media-type="text/xml" /><manifest:file-entry manifest:full-path="styles.xml" manifest:media-type="text/xml" /><manifest:file-entry manifest:full-path="meta.xml" manifest:media-type="text/xml" /><manifest:file-entry manifest:full-path="settings.xml" manifest:media-type="text/xml" /></manifest:manifest>

this file seems to be correctly loaded, but I'm not able of getting the node like:

$dom->at('manifest:file-entry[manifest:full-path="/"]')

I also try

  for my $e ($dom->find('urn:oasis:names:tc:opendocument:xmlns:manifest:1.0:file-entry')->each) {
    say $e->text;
  }

and nothing

What am I doing wrong?

Best Regards
Marcos Rebelo

Alister West

unread,
Jun 18, 2012, 5:26:05 PM6/18/12
to mojol...@googlegroups.com
Namespace prefix's aren't mandatory in css selectors but if you want
to use them then try escaping the separator so it doesn't get treated
like a pseudo-class.

my $dom = Mojo::DOM->new($xml);

# escaped namespace separator
say $dom->at('manifest\:file-entry[manifest\:full-path="/"]')->{'manifest:media-type'};

# without namespace prefix
say $dom->at('file-entry[full-path="/"]')->{'manifest:media-type'};

Have a look at the namespace tests for mojo::dom which is pretty easy
to understand.
https://github.com/kraih/mojo/blob/master/t/mojo/dom.t#L403

Cheers,

~~
 c|_|  alisterwest.com - mmm coffee!
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To post to this group, send email to mojol...@googlegroups.com.
> To unsubscribe from this group, send email to
> mojolicious...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mojolicious?hl=en.

marcos rebelo

unread,
Jun 19, 2012, 12:28:43 AM6/19/12
to mojol...@googlegroups.com
Thanks
Reply all
Reply to author
Forward
0 new messages