[erlang-questions] xmerl question

jla415 jla415@REDACTED
Sun Jul 22 10:18:23 CEST 2007




Brad Anderson-3 wrote:
> 
> Hi,
> 
> I am not getting a match correct...
> 
> For the #xmlElement like:
> 
> <matchup kickoff="1189125000" gameSecondsRemaining="3600">
>   <team id="NOS" isHome="0" score=""/>
>   <team id="IND" isHome="1" score=""/>
> </matchup>
> 
> I'm trying to parse it with:
> 
> parse_matchup(Matchup) ->
>     #xmlElement{attributes=Attribs, content=Content} = Matchup,
>     [ #xmlAttribute{name=kickoff, value=Kickoff} ] = Attribs,
>     Kickoff.
> 
> 
> I'm getting a badmatch [1] when I try to get the value of the 'kickoff'
> attribute.  Any idea what I'm doing wrong?
> 

In that particular instance of xml you have multiple attributes, so the
pattern match would need to be something along the lines of:

    [#xmlAttribute{name=kickoff, value=Kickoff}|_] = Attribs,

but be aware this way depends on the kickoff attribute being first in the
element so its still pretty fragile.

-- 
View this message in context: http://www.nabble.com/xmerl-question-tf4124134.html#a11729169
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list