Re: [xml] libxml tutorial



On Tue, Jun 04, 2002 at 09:49:41AM +0200, Francois Chenais wrote:
Hello, 

      How about an simple example using Xpath to do thing LIKE this.

<example>
      xmlDocPtr doc = xmlParseFile(docname);

      title = getKeyword(doc, "/mail/title");

   Sorry I didn't answer your previous request on the subject, but it's
overly simplistic the API would be too limited, you need to also pass
namespaces mappings. For example at an XPath level if mail and title
are in the default namespace your query would not select the nodes.
Also such a query returns a node set, not a simple node in general
(actually it returns a XPath object, could be a number, string ...).

      setKeyword(doc, "/mail/title", "Simple xml example");

   Also the idea of Keyword is not an XML context, setText would be more
appropriate, XML just sees a sequence of characters at that level.

      And same function for setAttribut, getAttribut.

   Actually, why ? XPath can indifferently select elements, text or
attributes nodes, there is no need to make a specific distinction at
that level. Fine for an example but it's too oriented by your vision
of your specific case, and if suggesting a specific API in the tutorial
it might be a good idea to have it follow closely the semantic of the
underlying operations, no ?

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]