Php+xml Cache How to quickly read a specified value
Using XML caching
Structure is
-
-
1
B007
-
2
B001
-
3
B000
-
4
B004
-
5
B003
..............
Copy Code
More data
Now I want to quickly find
PD value of id=4
or id=4 all values for the following item
What should I write?
One more question, can XML support dynamic read values?
Like a.xml?id=4.
This type of
May I? Thank you
It's PHP.
------Solution--------------------
Reference: http://topic.csdn.net/u/20120521/03/527bc4d2-b4e0-4d6e-9ae4-021a675cfff5.html
------Solution--------------------
PHP Code
$xml =simplexml_load_file (' Bb.xml '); foreach ($xml->item as $v) {if ($v->id==4) echo "ID: $v->id
PD: $v->pd ";}
------Solution--------------------
XPath, do you have any other answers?
PHP code
[user:root time:10:28:18 path:/home/liangdong/php]$
PHP xpath.php PD b004[user:root time:10:28:19 path:/home/liangdong/php]$ cat xpath.php!--? php$str = <<
1
B007
2
B001
3
B000
4
B004
5
B003
EOF, $xml = simplexml_load_string ($str, "SimpleXMLElement", libxml_noblanks), $res = $xml->xpath ("/channe L/item/id[text () =4]/parent::item/pd "), foreach ($res as $node) {echo $node->getname (). " " . $node->{0}. Php_eol;}?