0

Is it possible to search for text within an SimpleXML object directly, or does it need to be converted to a string first?

hakre
  • 193,403
  • 52
  • 435
  • 836
MrDave
  • 417
  • 1
  • 6
  • 18
  • Why you can't just make another SimpleXML object for the error xml? and the parse the text content of the datafeed element. – adrian7 Dec 07 '14 at 23:09
  • The error xml has the same filename. But even if it didn't, my question is still what php code will allow me to search for 'Code 1' in that SimpleXML object as part of my if statement. – MrDave Dec 07 '14 at 23:26
  • Have you tried converting the object(s) to string? – adrian7 Dec 08 '14 at 12:13
  • Thanks adrian7 - I wondered whether there was a way of doing it directly, that is all. – MrDave Dec 08 '14 at 21:53
  • 4
    You can perform xpath searches for text containing a string. http://stackoverflow.com/questions/5074469/xpath-find-text-in-any-text-node – Michael Berkowski Dec 08 '14 at 21:54
  • Your question in this simplified form is not really clear to me. If I search a string I somehow will always need to convert what I search to a string as well - otherwise I could not compare the string I search for. In any case, the answer to your question is: Yes, it is possible. – hakre Dec 22 '14 at 10:50

0 Answers0