Jump to content

XML


Drakath

Recommended Posts

  
  
-- iterate over all the xml nodes and find those whose value and  tag name matches...  
local children = xmlNodeGetChildren(root); 
  
for _, child in ipairs(children) do  
     if (xmlNodeGetName(child) == tagName) and (xmlNodeGetValue(child) == someValue) then  
        xmlDestroyNode(child); 
     end;   
end; 
  
  

Link to comment
That requires to define index.
index: This is the 0-based index of the node you wish to find. For example, to find the 5th subnode with a particular name, you would use 4 as the index value. To find the first occurence, use 0.
This is a different index than what you mean.
Link to comment

Well it only returns the first line. While for the Vector's code, I tried this:

local xmlFile = xmlLoadFile("blocks.xml") 
local children = xmlNodeGetChildren(xmlFile) 
outputChatBox(playername) 
for _, child in ipairs(children) do 
outputChatBox(xmlNodeGetValue(child)) 
if (xmlNodeGetValue(child) == playername) then 
xmlDestroyNode(child) 
outputChatBox("deleted") 

playername outputted correctly but xmlNodeGetValue(child) outputted nil. Why?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...