Suppose I have this XML file:
<attributes> <units> <civilians> <unit> <name>Settler</name> <stats> <attack>26</attack> <defence>7</defence> </stats> <costs> <lumber/> <iron/> </costs> </unit> <unit> <name>Infantry</name> <stats> <attack>33</attack> <defence>7</defence> </stats> <costs> <lumber/> <iron/> </costs> </unit> </civilians> </units> </attributes>
Does getElementsByTagName ("attack") receive node NodeList attributes with an attack element containing 26 in the first position and an attack element containing 33 in the second position?
I thought it was, but it doesn't seem to work.
If it is not as simple as that; What is a good way to capture all attack values from an XML file? Maybe the XML file itself is poorly structured?
Edit: Ah. Now I get the nodes, and .getTextContent () and not .getNodeValue () solved my problems. Sorry for the inconvenience.
source share