2012-12-31 41 views
-1

我想通過DDXMLDocument遞歸循環,並更改元素屬性。DDXMLDocument上的遞歸循環objective-c

我該怎麼辦?我目前擁有的文件和根元素:

DDXMLDocument *theDocument = [[DDXMLDocument alloc] initWithXMLString:content options:0 error:&error]; 
    DDXMLElement *rootElement = theDocument.rootElement; 

回答

1

後綴樹散步實現:

-(void)processNode:(DDXMLNode *)node { 
    if(node.kind == DDXMLElementKind) { 
     //... 
     for(DDXMLNode *child in node.children) { 
      [self processNode:child]; 
     } 
    } 
} 
+0

這應該是這樣的: - (無效)processNode:(DDXMLNode *)節點當然 – Dejell

+0

UPS混合up C和objC - 抱歉 –

+0

謝謝。順便說一句,如果我將DDXMLDocument作爲方法的第一個根發送,它也會解析。我怎樣才能發送它沒有這個元素? – Dejell