Re: [xml] getting/putting variables

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Wed Jan 12 2000 - 04:05:06 EST


[ Do not Cc xml@rufus.w3.org when sending mail to xml@xmlsoft.org,
  that's the same list/machine and you are just sending the message
  twice, Daniel ]

On Tue, Jan 11, 2000 at 07:39:17PM -0500, Anthony Tekatch wrote:
>
>
> Is there an easy way of getting or putting variables into the XML image in
> memory rather than recursively parsing it.
>
>
> >From the following XML code snippet:
> <my>
> <variable>
> 23
> </variable>
> </my>
>
>
> I would like to get variables like this:
>
> myvariable = doc->my.variable.val;
>
>
> I would like to variables like this:
>
> doc->my.variable.val = myvariable;
>
>
> Is something like this possible?

this is too application specific to be included by default in libxml
try to design a pair of function to do this, This won't be harder to
use.
  BTW your naming scheme can't work you can have sibling with the same
name:

 <my>
    <variable>12</variable>
    <variable>14</variable>
 </my>

what would be doc->my.variable.val ? 12 ? 14 ? 13 ? ...
Look at the XPath [1] syntax and design functions like

  myvariable = xmlValue(doc, "/my/variable[1]");

you can reuse the xpath code to get teh list of nodes corrsponding to
the second argument passed to the function. Look at the xmlShell() in
debugXML.c implementation it uses XPath in similar ways:

http://xmlsoft.org/gnome-xml-debugxml.html#XMLSHELL

Daniel

[1] http://www.w3.org/TR/xpath

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux XML libxml WWW
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind
 http://www.w3.org/People/all#veillard%40w3.org  | RPM badminton Kaffe
----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:29:58 EDT