title: Create String Array with XML attributes in Visual Basic
body: <p>I am trying to pull information from a onenote notebook. The only way I've found to be able to is to get the hierarchy of the notebook, then pull all the attributes so I can use them to pull the actual content of a page. Following is an example of the XML document.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;one:Notebooks xmlns:one="http://schemas.microsoft.com/office/onenote/2013/onenote"&gt;
      &lt;one:Notebook name="Notebook" nickname="Notebook" ID="**********" path="**********" lastModifiedTime="**********" color="**********"&gt;
          &lt;one:Section name="**********" ID="**********" path="**********" lastModifiedTime="**********" color="**********"&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="1"/&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="2"/&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="1"/&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="2"/&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="2"/&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="2"/&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="1"/&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="2"/&gt;
              &lt;one:Page ID="**********" name="**********" dateTime="**********" lastModifiedTime="**********" pageLevel="2"/&gt;
          &lt;/one:Section&gt;
      &lt;/one:Notebook&gt;
  &lt;/one:Notebooks&gt;
  </code></pre>
  
  <p>I was able to pull the attributes by using the following:</p>
  
  <pre><code>Dim oneNote = New OneNote.Application()
  oneNote.GetHierarchy(Nothing, Microsoft.Office.Interop.OneNote.HierarchyScope.hsPages, strXML)
          Dim xdoc As New XmlDocument()
          xdoc.LoadXml(strXML)
      For Each Element As XmlElement In xdoc.SelectNodes("//*")
          TextBox1.Text = TextBox1.Text &amp; "Processing element with name: " &amp; Element.Name &amp; Environment.NewLine
          For Each Attribute As XmlAttribute In Element.Attributes
              TextBox1.Text = TextBox1.Text &amp; Convert.ToChar(Keys.Tab) &amp; Attribute.Name &amp; ": " &amp; Attribute.Value &amp; Environment.NewLine
          Next
          TextBox1.Text = TextBox1.Text &amp; Environment.NewLine
      Next
  </code></pre>
  
  <p>However when I try to pull specific attributes by name it comes back with a namespace error.</p>
  
  <pre><code>For Each node As XmlNode In xdoc.DocumentElement.SelectNodes("//one:Notebooks/one:Notebook/one:Section")
      TextBox1.Text = TextBox1.Text &amp; node.Attributes.ItemOf("name").InnerText &amp; Environment.NewLine
  Next
  </code></pre>
  
  <p>I would like to be able to create a string array with the name of the section, the name of the page, the ID of the page, and the page level. Any help would be much appreciated.</p>