ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* XML - creating a list by hand (mkiv)
@ 2009-12-21 13:36 Peter Rolf
  2009-12-22 13:04 ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Rolf @ 2009-12-21 13:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

can someone give me a helping hand with the following example. I still 
have no general survey over the XML related code in ConTeXt (donno what 
functions to use). The last time I played with it is one and a half year 
ago and many things have changed (meaning that the old examples no 
longer work).

I simply want to create a XML document and insert some elements. My main 
problem is to insert an element at root level. I can insert an element 
before and after another element, but not into the element. I'm not 
sure, if I have understood the meaning of the pattern parameter 
correctly. Is this equal to XPath?


%-----
\starttext

\startluacode

local xmp = xml.convert("<?xml version='1.0' 
standalone='yes'?>\n<root>\n<bar>bla</bar>\n</root>")
--xml.before(xmp,"/root/bar","<sub>foo</sub>")

--xml.delete(xmp,"bar")
--xml.inject(xmp,"/sub","<sub>bar</sub>")-- only for xml-files?

xml.insert(xmp,"/root/bar","<sub/>")
--xml.inject(xmp,"/*/bar","<sub/>")

--xml.sprint(xml.filter(xmp,"/root/sub"))

xml.save(xmp,"test.xml")

\stopluacode

\stoptext
%-----


Best wishes,  Peter
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-13 22:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-21 13:36 XML - creating a list by hand (mkiv) Peter Rolf
2009-12-22 13:04 ` Hans Hagen
2009-12-22 13:21   ` Peter Rolf
2009-12-22 13:33     ` Hans Hagen
2010-01-12 14:47       ` Peter Rolf
2010-01-13 22:10         ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).