Re: [xml] quick value finding



On Sat, Apr 10, 2004 at 08:20:39PM +0100, skyhawk redbrick dcu ie wrote:
I'm thrawling through the docs and anything I've found so far seems
overkill for what I want to do.
Basically if i have a file such as <test><entry>printed</entry></test>
i'd like to be able to do somthing along the lines of
cout<<valueOf("entry")<<endl; and have printed appear on screen.

I'm sure there must be a method somewhere in the library to allow me 
to get the values of a given tag.

  No. Because your use case is far too limited for real work.
Just for a start you may have multiple "entry" in a file. It's overkill
to you because you have a far too narrow view of the real needs. Such
an API would be basically useless, except maybe for you, since it would
  1/ only work with a global variable
  2/ would not work correctly with XML namespaces
  3/ would have semantic problem in case of multiple elements
Instead of trying to invent a new API without properly understanding
the context, learn about XPath and check the xpath1 example from
  http://xmlsoft.org/examples/
or use the reader interface and get the content of the (first ?) entry
node. 

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.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]