title: How do I add and display attributes in an element?
body: <p>Currently my function is only displaying elements but not their attributes. I am not sure how to add attributes to the elements. I can view all the elements in debug mode but the elements that need to have attributes do not have them. 
  For example
  I would like to see <code>&lt;Message MessageType="GetCodeListing" NodeID="1" ReferenceNumber="R-19293" UserID="8304" Source="IntegrationBroker"&gt;</code> but I only see <code>&lt;Message/&gt;</code> which means I need to add the attributes to this element. 
  How do I do this?</p>
  
  <p>Please note that <code>&lt;Word ExactMatch='true'&gt;07001G&lt;/Word&gt;</code> the <code>Word</code> is a variable and I am not sure how to add it. 
  I would like to have output that looks like this:</p>
  
  <pre><code>&lt;Transaction ReferenceNumber="CC-Add-Appl-Doc-06292015_05" Source="IntegrationBroker" TransactionType="Multi"&gt;
      &lt;DataPropagation&gt;
          &lt;IntraTxn xPath="/TxnResponse/Result[1]/Codes/Code/CodeID" ReplStr="#|CODEID|#"/&gt;
      &lt;/DataPropagation&gt;
      &lt;Message MessageType="GetCodeListing" NodeID="1" ReferenceNumber="R-19293" UserID="8304" Source="IntegrationBroker"&gt;
          &lt;CodeTypeID&gt;JUS136&lt;/CodeTypeID&gt;
          &lt;Search&gt;
              &lt;Word ExactMatch='true'&gt;07001G&lt;/Word&gt;
          &lt;/Search&gt;
      &lt;/Message&gt;
      &lt;Message MessageType="GetJudicialOfficerCode" NodeID="1" ReferenceNumber="R-19293" UserID="8304" Source="IntegrationBroker"&gt;
          &lt;CodeID&gt;#|CODEID|#&lt;/CodeID&gt;
      &lt;/Message&gt;
  &lt;/Transaction&gt;
  </code></pre>
  
  <p>My function creates a new document and adds elements into it. I am not sure how to add attributes to the elements and that is the help I need.</p>
  
  <pre><code> Function GetJudgeAPI(ByVal astrJudgeId As String) As XmlDocument
      Dim objXmlOutPutDoc As XmlDocument
      Dim objXmlTransactionDoc As XmlDocument
  
      'Create Transaction message
      objXmlTransactionDoc = New XmlDocument
      objXmlTransactionDoc.AppendChild(objXmlTransactionDoc.CreateElement("Transaction"))
      objXmlTransactionDoc.DocumentElement.SetAttribute("ReferenceNumber", System.Guid.NewGuid.ToString)
      objXmlTransactionDoc.DocumentElement.SetAttribute("Source", "IntegrationBroker")
      objXmlTransactionDoc.DocumentElement.SetAttribute("TransactionType", "Get Judge")
  
      'Add Data Propagation
      objXmlTransactionDoc.SelectSingleNode("Transaction").AppendChild(objXmlTransactionDoc.CreateElement("DataPropagation"))
      objXmlTransactionDoc.SelectSingleNode("Transaction/DataPropagation").AppendChild(objXmlTransactionDoc.CreateElement("IntraTxn"))
  
      'Add Message
      objXmlTransactionDoc.SelectSingleNode("Transaction").AppendChild(objXmlTransactionDoc.CreateElement("Message"))
      objXmlTransactionDoc.SelectSingleNode("Transaction/Message[1]").AppendChild(objXmlTransactionDoc.CreateElement("CodeTypeID"))
      objXmlTransactionDoc.SelectSingleNode("Transaction/Message[1]/CodeTypeID").InnerText = "JUS136"
      objXmlTransactionDoc.SelectSingleNode("/Transaction/Message[1]").AppendChild(objXmlTransactionDoc.CreateElement("Search"))
      objXmlTransactionDoc.SelectSingleNode("Transaction/Message[1]/Search").AppendChild(objXmlTransactionDoc.CreateElement("Word"))
      'Message 2
      objXmlTransactionDoc.SelectSingleNode("Transaction").AppendChild(objXmlTransactionDoc.CreateElement("Message"))
      objXmlTransactionDoc.SelectSingleNode("Transaction/Message[2]").AppendChild(objXmlTransactionDoc.CreateElement("CodeID"))
      objXmlTransactionDoc.SelectSingleNode("Transaction/Message[2]/CodeID").InnerText = "#|CODEID|#"
  
  End Function
  </code></pre>