dom - PHP - DOMXpath - Get the value -


यह मेरा कोड है:

  $ doc = new DOMDocument; $ डॉक्टर & gt; loadHTML ($ स्रोत); $ Xpath = नया DOMXPath ($ doc); $ परिणाम = $ xpath- & gt; मूल्यांकन करें ($ xpath); विदेशी मुद्रा ($ नोड के रूप में $ परिणाम) {गूंज $ नोड- & gt; नोड वेला; } // मैं में href विशेषता प्राप्त करने की कोशिश कर रहा हूं: & lt; a href = "http://example.com/login" & gt; लॉग इन & lt; / a & gt;   

जब मैं इसका मूल्यांकन करता हूं, तो मुझे केवल लॉग इन मिलता है

मुझे http://example.com/login

प्राप्त करना चाहते हैं, जब मैं पायथन के एलएक्सएमएल का उपयोग करता हूं और उस अभिव्यक्ति का मूल्यांकन करता हूँ, तो यह ठीक काम करता है। / $ P>

  foreach ($ नोड के रूप में परिणाम) {echo $ node- & gt; getAttribute ('href '); }   

नोड के पाठ मूल्य प्राप्त करने के लिए nodeValue संपत्ति का उपयोग किया जाता है।

getAttribute () विधि एक विशेषता का मान देता है।

Comments

Popular posts from this blog

Delphi: missing interface declarations for UI Automation methods -

php - how to change mysql_result($res, 0, "url"); to mysqli -

android - How to attach an image from an app to gmail -