I'm having a little bit of trouble, I've read through tutorials on parsing XML to Javascript and such, but the XML file I'm working with is very different to the ones the tutorial showed me.
Normally it'd be like
Code:
<here>
<there></there>
</here>
But the one I'm wanting to work in looks like this:
Ahhh...you missed the /> of the inner <row... in your first post.
*NOW* it's legal.
Well, you *can* simply do something like
Code:
var rows = xml.getElementsByTagName("row");
for ( var r = 0; r < rows.length; ++r )
{
var row = rows[r];
if ( row.name == "CORE." )
{
... do something ...
}
}
or similar. That is, process all elements of a given tag name looking for a match on characteristics.
You can also do it by looking for <row> inside of <rowset> inside of <row>, etc.
So not sure how complex this XML grows to. If no worse than what you showed, should be fine.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
So does that one *always* have a corporationID property?
If so, you could simply look for that property existing.
Code:
var rows = xml.getElementsByTagName("row");
for ( var r = 0; r < rows.length; ++r )
{
var row = rows[r];
if ( row.corporationID != null )
{
... do something ...
}
}
No?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
First use the technique I showed to find the specific <row> (that is, look for shortname property, look for particular value for shortname if desired).
Then simply do:
Code:
var subrows = row.getElementsByTagName("row");
for ( var s = 0; s < subrows.length; ++s )
{
var subrow = subrows[s];
... process one subrow...
}
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
var subrows = xmlDoc.getElementsByTagName("row");
for ( var s = 0; s < subrows.length; ++s )
{
var subrow = subrows[s];
document.write(subrow.name + '<br>');
}