PDA

View Full Version : escaping XML "queries"



benh
October 9th, 2007, 06:28 AM
Hi there,

I'm stuck on an XML query because the XML uses the reserved word "for" in it's namespace;

The tricky bit of the XML looks like this;


<AwayRecord win="3" draw="1" lost="1" for="11" against="7" />

<HomeRecord win="4" draw="0" lost="1" for="10" against="3" />






This works

sFHomeFor = H2HData.ClubRecord[i].SeasonRecord.ResultsBreakdown.AwayRecord.@against

but this


sFHomeFor = H2HData.ClubRecord[i].SeasonRecord.ResultsBreakdown.AwayRecord.@for

causes a compile error;
"1084: Syntax error: expecting identifier before for."

Any ideas? This one's got me stumped...

Cheers

Ben

ff45t1z
October 9th, 2007, 06:49 AM
As far as I know, you'll need to change the attribute in the XML, I had problems like this with 'name' and 'x' and such, so I just changed them, and it obviously worked fine.
Since you're using Flash I'll assume you're not printing directly from XML, so you'll be able to relabel them if you wish. I'd suggest doing things this way.

benh
October 9th, 2007, 07:03 AM
Nope - it's a feed - so no option of changing it unfortunately...

SpaceHunter
October 9th, 2007, 09:39 AM
Hi there,

I'm stuck on an XML query because the XML uses the reserved word "for" in it's namespace;

The tricky bit of the XML looks like this;


<AwayRecord win="3" draw="1" lost="1" for="11" against="7" />

<HomeRecord win="4" draw="0" lost="1" for="10" against="3" />


This works

sFHomeFor = H2HData.ClubRecord[i].SeasonRecord.ResultsBreakdown.AwayRecord.@against but this


sFHomeFor = H2HData.ClubRecord[i].SeasonRecord.ResultsBreakdown.AwayRecord.@for
causes a compile error;
"1084: Syntax error: expecting identifier before for."

Any ideas? This one's got me stumped...

Cheers

Ben
use .@["for"];

benh
October 10th, 2007, 08:14 AM
That did it - many thanks SpaceHunter!