PHP regular expressions are used to retrieve 17 & nbsp; & lt ;? Xmlversion = & quot; 1.0 & quot; encoding = & quot; UTF-8 & quot ;? & Gt; & lt; response & gt; & lt; error & gt; 17 & lt;/error & gt; & lt; message & gt; synchronous sending of instant PHP regular expressions
Now use the regular expression to retrieve 17
17
Synchronously send instant SMS response results
I wrote it like this.
Preg_match ("/\ (. *) \ <\/Error \>/U ", $ string, $ state );
But output:
Array
(
[0] => 17
[1] => 17
)
What are the mistakes? I still use them.
Simplexml_load_string: an error is returned when parsing this XML file. This function is used to retrieve This node does not work. now only regular expressions can be used.
Table Help. thank you.
------ Solution --------------------
1. Regular expressions are correct.
You can use $ state [1] to get the error node value.
2. simplexml_load_string () if an error is reported. It is probably because of the file BOM header or inconsistent encoding.
------ Solution --------------------
The one you output is correct.
------ Solution --------------------
Your regular expression is correct. you can get $ state [1] and ignore the previous one.
When you use simplexml_load_string, the error code is "line breaks" in xml.
PHP code
17
Synchronously send instant SMS response results
'; $ Obj = simplexml_load_string (str_replace (array ("\ r", "\ n", "\ t"), '', $ xml )); print_r ($ obj );
------ Solution --------------------
$ Xml = simplexml_load_string ($ s );
Echo $ xml-> error;
If an error occurs, it is because your encoding is inappropriate.