PHP XML DOM: working with a subsection of an xml document

Moreno

New Member
So I'm rather new to working with PHP's XML DOM. But I have trouble within the following problem. So imagine I have an xml document with several repeated sections, distinguishable by date. I'm trying to access a specific section by the date and then use tradition DOM methods to access data within that section. Here's what I'm currently doing.XML document\[code\]<quizzes> <quiz> <date>Yesterday</date> <question>This is the day's question</question </quiz> <quiz> <date>Today</date> <question>This is the day's question</question </quiz> <quiz> <date>Tomorrow</date> <question>This is the day's question</question </quiz></quizzes\[/code\]PHP Code\[code\]$xmlDoc = new DOMDocument()$xmlDoc->load($aboveXMLFile)$subSection = $xmlDoc->getElementsByTagName("quiz")->item(0)$dateofSubSection = $subSection->getElementsByTagName("date")->item(0)->nodeValue;echo $dateofSubSection\[/code\]I'm getting an error that says \[code\]getElementsbyTagName\[/code\] is not a valid method for \[code\]$subSection\[/code\]. Why?And if I can't do this, how can select the subsection by date and then subsequently access nodeValues within that subsection alone?Thanks for your help
 
Back
Top