Search notes:

VBA: MSXML and DOM - selectSingleNode

selectSingleNode(query) allows to evaluate an XPath expression on an XML document.
option explicit

sub main() ' {

   dim doc as new MSXML2.DOMDocument

   doc.loadXML(                             _
     "<items>"                            & _
     "  <fruit id='1000'>Apple</fruit>"   & _
     "  <fruit id='1001'>Banana</fruit>"  & _
     "  <fruit id='1002'>Cherry</fruit>"  & _
     "  <city  id='2000'>Paris</city>"    & _
     "  <city  id='2001'>Berlin</city>"   & _
     "  <city  id='2002'>Zürich</city>"   & _
     "</items>")


    debug.print(doc.selectSingleNode("//*[@id='1001']").text) ' Banana

    debug.print(doc.selectSingleNode("/items/city[2]").text)  ' Zürich

end sub ' }
Github repository about-VBA, path: /object-libraries/MSXML/DOM/selectSingleNode.bas

See also

selectNodes(…)
selectSingleNode() then selectNodes()
MSXML and DOM

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759398442, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/Useful-object-libraries/MSXML/DOM/selectSingleNode(68): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78