Php 删除所有子节点并使用simpleXML获取内容
我想获取一个变量中所有子节点的内容。例如:Php 删除所有子节点并使用simpleXML获取内容,php,xml,simplexml,Php,Xml,Simplexml,我想获取一个变量中所有子节点的内容。例如: <p><distinct type="twitter-retweet"><ident>RT</ident> <addressingTerm><addressMarker>@</addressMarker><addressee type="twitter-account" ref="https://twitte
<p><distinct type="twitter-retweet"><ident>RT</ident>
<addressingTerm><addressMarker>@</addressMarker><addressee type="twitter-account"
ref="https://twitter.com/LePG 35022597"
>LePG</addressee></addressingTerm>:</distinct> A 07h50,
<addressingTerm><addressMarker>@</addressMarker><addressee type="twitter-account"
ref="#cmr-politweets-p80820758">JLMelenchon</addressee></addressingTerm> est
l'invité des #4vérités sur <distinct type="twitter-hashtag"><ident>#</ident><rs
ref="https://twitter.com/search?q=%23France2&src=hash"
>France2</rs></distinct>. Nous live-tweeterons. #Chômage <distinct
type="twitter-hashtag"><ident>#</ident><rs
ref="https://twitter.com/search?q=%23Municipales2014&src=hash"
>Municipales2014</rs></distinct></p>
RT
@LePG:A 07h50,
@梅伦钦东部
法兰西河畔因维特酒店2。我们现场直播推特#2014年科马吉市
我想在这句话的输出中:
“RT@LePG A 07h50,@JLMelenchon est l'invitédes#4vérités sur#France2.我们的实时推特。城市2014”
问题是当我使用asXML()时,变量中还有节点
谢谢如果您不必使用simpleXML,并且可以将XML作为字符串获取,那么这可能看起来有点像是一种逃避:我建议您只需使用“strip_标记” 否则,您将需要递归地解析子级以构建字符串。如有必要,我将使用递归函数进行更新