def fetchArticleIdNameDict(artilceListPath): articleListXml=xmlSp() xmlTree=articleListXml.fetchXmlNodeTree(artilceListPath) idList=articleListXml.fetchNodeValueList(xmlTree,'id') nameList=articleListXml.fetchNodeValueList(xmlTree,'name') idNameDict=twoListToDict(idList,nameList) return idNameDict
def updateArticleList(articleIdList,articleNameList): articleListXml = xmlSp() nodeTree = articleListXml.fetchXmlNodeTree(articleListPath_) rootNode=articleListXml.fetchSingleNode(nodeTree,'articleList') for index in range(len(articleIdList)): articleId=articleIdList[index] articleName=articleNameList[index] idNode=articleListXml.createChildNode('id',str(articleId)) nameNode=articleListXml.createChildNode('name',str(articleName)) parentNode=articleListXml.createChildNode('article','') articleListXml.addNode(parentNode,idNode) articleListXml.addNode(parentNode,nameNode) articleListXml.addNode(rootNode,parentNode) articleListXml.writeXml(nodeTree,articleListPath_)
def fetchArticleIdList(artilceListPath): articleListXml=xmlSp() xmlTree=articleListXml.fetchXmlNodeTree(artilceListPath) idList=articleListXml.fetchNodeValueList(xmlTree,'id') return idList