ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to get attribute value from xml tag?
@ 2019-10-20 14:05 Geert Verhaag
  2019-10-20 14:38 ` Thomas A. Schmitz
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Verhaag @ 2019-10-20 14:05 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 370 bytes --]

Hi,

Struggling with XML in ConTeXt.

I'have the following tag in my xml file:

...
<invoice>
   <travel>
     <distance unit="km">20</distance>
   </travel>
...
</invoice>

\startxmlsetups xml:invoice:travel
   \xmlfirst{#1}{distance}
\stopxmlsetups

The \xmlfirst{#1}{distance} yields /20/, but how can the unit attribute 
value /km/ be accessed?

Gerard

-- 



[-- Attachment #1.2: Type: text/html, Size: 1175 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: How to get attribute value from xml tag?
  2019-10-20 14:05 How to get attribute value from xml tag? Geert Verhaag
@ 2019-10-20 14:38 ` Thomas A. Schmitz
  2019-10-20 17:13   ` Geert Verhaag
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas A. Schmitz @ 2019-10-20 14:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users



> On 20. Oct 2019, at 16:05, Geert Verhaag <verhaaggchm@ziggo.nl> wrote:
> 
> The \xmlfirst{#1}{distance} yields 20, but how can the unit attribute value km be accessed?
> 
> Gerard
> 
> 

\xmlattribute{#1}{/distance}{unit}

(probably, you need to make a real example. See xml-mkiv.pdf, chapter 3.6)

Thomas
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: How to get attribute value from xml tag?
  2019-10-20 14:38 ` Thomas A. Schmitz
@ 2019-10-20 17:13   ` Geert Verhaag
  0 siblings, 0 replies; 3+ messages in thread
From: Geert Verhaag @ 2019-10-20 17:13 UTC (permalink / raw)
  To: ntg-context

On 20-10-19 16:38, Thomas A. Schmitz wrote:
>
>> On 20. Oct 2019, at 16:05, Geert Verhaag <verhaaggchm@ziggo.nl> wrote:
>>
>> The \xmlfirst{#1}{distance} yields 20, but how can the unit attribute value km be accessed?
>>
>> Gerard
>>
>>
> \xmlattribute{#1}{/distance}{unit}
>
> (probably, you need to make a real example. See xml-mkiv.pdf, chapter 3.6)
>
> Thomas
> ___________________________________________________________________________________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________


-- 

Hi,

Thomas, thanks a lot, and it is fairly simple if you know how to read 
the following (taken from page 22, chapter 3.6):

\xmlattribute {...} {...} {...}
finds a first match for LPATH at NODE and returns the value of attribute 
NAME or empty if no such
attribute exists

But now I get it, thanks!

Regards,
Gerard

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2019-10-20 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-20 14:05 How to get attribute value from xml tag? Geert Verhaag
2019-10-20 14:38 ` Thomas A. Schmitz
2019-10-20 17:13   ` Geert Verhaag

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).