Thanks Michael. I'm using C++ and have not figured it out. I'm
wondering how I can get these namespace URIs. information

On Wed, Sep 2, 2009 at 4:23 AM, Michael Ludwig<[email protected]> wrote:
> Jianqing Zhang schrieb:
>>
>> I'm trying to read all namespace URIs by go through all attributes of
>> the root element. Can I read them as regular attributes?
>
> Jianqing,
>
> I don't know the C API, but in general, a parser may have a flag to
> turn namespace-awareness on or off.
>
> I'm not sure LibXML2 has this flag, though; namespace-awareness may
> be on by default. And in that case, you probably cannot read them as
> regular attributes, because they're made available through a different
> part of the API.
>
> After coding the following sample in Perl, I'm unsure what the rule is
> for namespaces and attributes - because here I can see the namespace
> attributes not only using $node->getNamespaces(), but alos using
> $node->attributes().
>
> use strict;
> use warnings;
> use XML::LibXML;
> my $parser = XML::LibXML->new;
> my $doc = $parser->parse_string(
>        q{<Urmel xmlns="urn:urmel" xmlns:milu="urn:milu" x="3"/>});
> print "\ngetNamespaces:\n";
> print $_->name, "\t", $_->value, "\n"
>        for $doc->documentElement->getNamespaces;
> print "\nattributes:\n";
> print $_->name, "\t", $_->value, "\n"
>        for $doc->documentElement->attributes;
>
> m...@colinux:~/Werkstatt/perl/xml > perl xml-libxml-ns.pl
>
> getNamespaces:
> xmlns   urn:urmel
> xmlns:milu      urn:milu
>
> attributes:
> x       3
> xmlns   urn:urmel
> xmlns:milu      urn:milu
>
> --
> Michael Ludwig
> _______________________________________________
> xml mailing list, project page  http://xmlsoft.org/
> [email protected]
> http://mail.gnome.org/mailman/listinfo/xml
>
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to