title: How do I extract text of a single HTML element by tag name using MSXML in VBA?
body: <p>I'm trying to extract US Patent titles using MSXML6.</p>
  
  <p>On the full-text html view of a patent document on the USPTO website, the patent title appears as the first and only "font" element that is a child of "body".</p>
  
  <p>Here is my function that is not working (I get no error; the cell with the formula just stays blank).</p>
  
  <p>Can somebody help me figure out what is wrong?</p>
  
  <p>An example URL that I am feeding into the function is <a href="http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&amp;Sect2=HITOFF&amp;d=PALL&amp;p=1&amp;u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&amp;r=1&amp;f=G&amp;l=50&amp;s1=6293874.PN.&amp;OS=PN/6293874&amp;RS=PN/6293874" rel="nofollow">http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&amp;Sect2=HITOFF&amp;d=PALL&amp;p=1&amp;u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&amp;r=1&amp;f=G&amp;l=50&amp;s1=6293874.PN.&amp;OS=PN/6293874&amp;RS=PN/6293874</a></p>
  
  <pre><code>Function getUSPatentTitle(url As String)
      Static colTitle As New Collection
      Dim title As String
      Dim pageSource As String
  
      Dim xDoc As MSXML2.DOMDocument
      Dim xNode As IXMLDOMNode
  
      On Error Resume Next
  
      title = colTitle(url)
      If Err.Number &lt;&gt; 0 Then
          Set html_doc = CreateObject("htmlfile")
          Set xml_obj = CreateObject("MSXML6.XMLHTTP60")
  
          xml_obj.Open "GET", url, False
          xml_obj.send
          pageSource = xml_obj.responseText
          Set xml_obj = Nothing
  
          Set xDoc = New MSXML2.DOMDocument
          If Not xDoc.LoadXML(pageSource) Then  
              Err.Raise xDoc.parseError.ErrorCode, , xDoc.parseError.reason
          End If
  
          Set xNode = xDoc.getElementsByTagName("font").Item(1)
  
          title = xNode.Text
          If Not title = "" Then colTitle.Add Item:=title, Key:=url
      End If
  
      On Error GoTo 0 ' I understand "GoTo" is dangerous coding but copied from somebody and so far haven't thought of a more natural substitute for a GoTo statement
  
      getUSPatentTitle = title
  End Function
  </code></pre>