Skip to content

Latest commit

 

History

History
23 lines (20 loc) · 680 Bytes

0631.md

File metadata and controls

23 lines (20 loc) · 680 Bytes

Consider the following simple PHP script:

$dom = new DomDocument();
$dom->load('test.xml');
$xpath = new DomXPath($dom);
$nodes = $xpath->query(???????, $dom->documentElement);
echo $nodes->item(0)->getAttributeNode('bgcolor')->value . "\n";

What XPath query should go in the ?????? above to display the "bgcolor" attribute of the first "body" node in the XML document?

  • A) "*[local-name()='body']"
  • B) "/body[0]/text"
  • C) "/body/body[0]"
  • D) "name='body'"
Answer

Answer: A