How to traverse SimpleXML to edit text nodes?
问题 I need to implement the following algorithm with SimpleXML: put a XML fragment string into a SimpleXML object; traverse all the nodes, selecting text nodes; edit the text node (example convert to upper case); return the xml as string. PROBLEMS: How to load a XML with named entities (ex. ). To traverse XML to get only text nodes... With $sx->xpath('//text()'); I can not edit the nodes, how to select text nodes to edition? 回答1: You can override the text content of a node returned by a