Cambiar el valor del texto con lxml
Tengo un archivo xml - aquí hay un fragmento ...
<gmd_fileIdentifier>
<gco_CharacterString>{0328cb65-b564-495a-b17e-e49e04864ab7}</gco_CharacterString>
</gmd_fileIdentifier>
<gmd_identifier>
<gmd_RS_Identifier>
<gmd_authority gco_nilReason="missing" />
<gmd_code>
<gco_CharacterString>0000</gco_CharacterString>
</gmd_code>
<gmd_codeSpace xmlns:gml="http://www.opengis.net/gml" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<gco_CharacterString>test</gco_CharacterString>
</gmd_codeSpace>
</gmd_RS_Identifier>
</gmd_identifier>
Lo que quiero hacer es cambiar el valor de 0000 que está actualmente en la etiqueta, a la cadena de caracteres gmd_fileIdentifier {0328cb65-b564-495a-b17e-e49e04864ab7}.
Puedo acceder a los valores utilizando el siguiente código de Python, pero ¿cómo configuro el valor? Codigo actual
import os, sys
from lxml import etree
myXML = r"D:\test.xml"
tree = etree.parse(myXML)
root = tree.getroot()
root.xpath("//gmd_fileIdentifier/gco_CharacterString/text()")
print fileID
code = root.xpath("//gmd_identifier/gmd_RS_Identifier/gmd_code/gco_CharacterString/text()")
print code
Gracias