Re: [xml] C API question: reading attribute name?

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">

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

I think the solution is explained at
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 Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]