A
andyashton
How can I create a new XML object for processing using only elements
from a certain namespace? If I have a file like this:
<?xml version="1.0" encoding="UTF-8"?>
<sports xmlns
layer="http://www.mlb.com/players">
<sport>Baseball</sport>
<league>MLB</league>
<player
layer>
<player:name>Derek Jeter</player:name>
<player
osititon>Shortstop</player
osition>
</player
layer>
<player
layer>
<player:name>Andy Pettite</player:name>
<player
osititon>Pitcher</player
osition>
</player
layer>
</sports>
I think I should be able to access those elements in the 'player'
namespace like this:
// parse with E4X
var p = new Namespace("http://www.mlb.com/players");
// why does this default namespace declaration not work!?
var xml = new XML(text);
if(xml.p:
layer.length()) {
var playersElements = xml.p:
layer;
} else {
var playersElements = [xml];
}
for each(var players in playersElements) {
....process those elements...
}
But it doesn't seem to work. Can anyone point out where I'm going
wrong?
Thanks!
from a certain namespace? If I have a file like this:
<?xml version="1.0" encoding="UTF-8"?>
<sports xmlns
<sport>Baseball</sport>
<league>MLB</league>
<player
<player:name>Derek Jeter</player:name>
<player
</player
<player
<player:name>Andy Pettite</player:name>
<player
</player
</sports>
I think I should be able to access those elements in the 'player'
namespace like this:
// parse with E4X
var p = new Namespace("http://www.mlb.com/players");
// why does this default namespace declaration not work!?
var xml = new XML(text);
if(xml.p:
var playersElements = xml.p:
} else {
var playersElements = [xml];
}
for each(var players in playersElements) {
....process those elements...
}
But it doesn't seem to work. Can anyone point out where I'm going
wrong?
Thanks!