[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] C API question: reading attribute name?
- From: Daniel Veillard <veillard redhat com>
- To: Jeremy Enos <jenos ncsa uiuc edu>
- Cc: xml gnome org
- Subject: Re: [xml] C API question: reading attribute name?
- Date: Wed, 11 May 2005 02:01:11 -0400
On Tue, May 10, 2005 at 07:33:43PM -0500, Jeremy Enos wrote:
> I am a beginner with libxml, and I have a problem which hours of
> searching through the API documentation hasn't been able to help with.
>
> If I have a file which contains:
>
> <?xml version="1.0"?>
> <foo bar="blah">
> <t1>text</t1>
> </foo>
>
> How do I get the attribute name "bar"? I'm able to get the value of bar
> (blah) using xmlTextReaderGetAttribute(), but I can't seem to find a way
> to print out the attribute name itself (bar).
This sounds a lot like
http://mail.gnome.org/archives/xml/2004-October/msg00101.html
I think the solution is explained at
http://xmlsoft.planetmirror.com/xmlreader.html#Extracting1
You can either:
- loop with for all values of 0 .. AttributeCount() - 1
and use MoveToAttributeNo(no) then use Name()/Prefix()/NamespaceUri()...
- or use MoveToNextAttribute()
and similary use Name()/Prefix()/NamespaceUri()
the small Python example in that doc shows the second one.
I did not design this API, this is directly copied from C# xmlReader API.
> Is it possible using C bindings?
Hum, there is no "bindings" for C as the API is C. all this can be done
at the C level.
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]