Php+xml Cache How to quickly read a specified value

Source: Internet
Author: User
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;}?
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.