Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Parsing this XML works but the other one doesn't

This is SQL 2016 Developer.

I have an XML like this. This one works and I can get the value

declare @xml XML


set @xml = '<main>
    <title id="ida3144ace-0381-11e7-859c-c7e65b0ded31" identifier="/us/usc/t8">
      <num value="8">Title 8—</num>
      <heading>ALIENS AND NATIONALITY</heading>
      <note topic="miscellaneous" id="ida3144acf-0381-11e7-859c-c7e65b0ded31">
        <p>Current through 115-18</p>
      </note>
      <toc role="threeColumnTOC" id="ida3144ad0-0381-11e7-859c-c7e65b0ded31">
        <layout>
          <header style="-uslm-lc:I70" role="tocColumnHeader">
            <column class="tocHeaderLeft">Chap.</column>
            <column />
            <column style="-uslm-lc:I29" class="tocHeaderRight">Sec.</column>
          </header>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch1">1.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">General Provisions [Repealed or Omitted]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1">1</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch2">2.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Elective Franchise [Transferred]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s31">31</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch3">3.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Civil Rights [Transferred or Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s41">41</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch4">4.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Freedmen [Omitted]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s61">61</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch5">5.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Alien Ownership of Land [Transferred or Omitted]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s71">71</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch6">6.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Immigration [Transferred, Omitted, or Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s100">100</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch7">7.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Exclusion of Chinese [Omitted or Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s261">261</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch8">8.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">The Cooly Trade [Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s331">331</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch9">9.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Miscellaneous Provisions [Repealed or Transferred]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s351">351</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch10">10.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Alien Registration [Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s451">451</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch11">11.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Nationality [Repealed or Transferred]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s501">501</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch12">12.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Immigration and Nationality</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1101">1101</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch13">13.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Immigration and Naturalization Service</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1551">1551</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch14">14.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Restricting Welfare and Public Benefits for Aliens</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1601">1601</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch15">15.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Enhanced Border Security and Visa Entry Reform</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1701">1701</ref>
            </column>
          </tocItem>
        </layout>
      </toc>
      <chapter style="-uslm-lc:I81" id="ida3144ad1-0381-11e7-859c-c7e65b0ded31" identifier="/us/usc/t8/ch1">
        <num value="1">CHAPTER 1—</num>
        <heading>GENERAL PROVISIONS</heading>
        <section status="repealed" style="-uslm-lc:I80" id="ida3144ad2-0381-11e7-859c-c7e65b0ded31" identifier="/us/usc/t8/s1...18">
          <num value="1 to 18">§§ 1 to 18.</num>
          <heading> Repealed or Omitted</heading>
          <notes type="uscNote" id="ida3144ad3-0381-11e7-859c-c7e65b0ded31">
            <note topic="removalDescription" id="ida3144ad4-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">These sections, relating to citizenship, were affected by the Nationality Act of 1940, former section 501 et seq. of this title.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad5-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">That act was passed on <date date="1940-10-14">Oct. 14, 1940</date>, to consolidate and restate the laws of the United States regarding citizenship, naturalization, and expatriation, and, in addition to certain specific repeals thereby, all acts or parts of acts in conflict with its provisions were repealed by former <ref href="/us/usc/t8/s904">section 904 of this title</ref>. See the notes below for history of individual sections.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad6-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 1, relating to citizenship of persons born in the United States, was repealed by <ref href="/us/act/1940-10-14/ch876/tI">act Oct. 14, 1940, ch. 876, title I</ref>, subch. V, § 504, <ref href="/us/stat/54/1172">54 Stat. 1172</ref>. It was from R.S. § 1992, which was revised from <ref href="/us/act/1866-04-09/ch31">act Apr. 9, 1866, ch. 31</ref>, § 1, <ref href="/us/stat/14/27">14 Stat. 27</ref>. Similar provisions were contained in former <ref href="/us/usc/t8/s601/a">section 601(a) of this title</ref>. See <ref href="/us/usc/t8/s1401">section 1401 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad7-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 2, relating to citizenship of persons born in Territory of Oregon, was from R.S. § 1995, which was revised from <ref href="/us/act/1872-05-18/ch172">act May 18, 1872, ch. 172</ref>, § 3, <ref href="/us/stat/17/134">17 Stat. 134</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad8-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 3 to 3c, related to citizenship of Indians. Section 3 was from acts <ref href="/us/act/1887-02-08/ch119">Feb. 8, 1887, ch. 119</ref>, § 6, <ref href="/us/stat/24/390">24 Stat. 390</ref>; <ref href="/us/act/1901-03-03/ch868">Mar. 3, 1901, ch. 868</ref>, <ref href="/us/stat/31/1447">31 Stat. 1447</ref>; <ref href="/us/act/1906-05-08/ch2348">May 8, 1906, ch. 2348</ref>, <ref href="/us/stat/34/182">34 Stat. 182</ref>; <ref href="/us/act/1919-11-06/ch95">Nov. 6, 1919, ch. 95</ref>, <ref href="/us/stat/41/350">41 Stat. 350</ref>; <ref href="/us/act/1921-03-03/ch120">Mar. 3, 1921, ch. 120</ref>, § 3, <ref href="/us/stat/41/1250">41 Stat. 1250</ref>; <ref href="/us/act/1924-06-02/ch233">June 2, 1924, ch. 233</ref>, <ref href="/us/stat/43/253">43 Stat. 253</ref>; <ref href="/us/act/1940-10-14/ch876">Oct. 14, 1940, ch. 876</ref>, title I, subch. V, § 504, <ref href="/us/stat/54/1173">54 Stat. 1173</ref>. Section 3a was from <ref href="/us/act/1930-06-19/ch544">act June 19, 1930, ch. 544</ref>, <ref href="/us/stat/46/787">46 Stat. 787</ref>. Section 3b was from acts <ref href="/us/act/1934-05-07/ch221">May 7, 1934, ch. 221</ref>, § 1, <ref href="/us/stat/48/667">48 Stat. 667</ref>; <ref href="/us/act/1947-07-23/ch304">July 23, 1947, ch. 304</ref>, § 1, <ref href="/us/stat/61/414">61 Stat. 414</ref>. Section 3c was from <ref href="/us/act/1934-05-07/ch221">act May 7, 1934, ch. 221</ref>, § 2, <ref href="/us/stat/48/667">48 Stat. 667</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad9-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 4, relating to citizenship of Hawaiians, was from <ref href="/us/act/1900-04-30/ch339">act Apr. 30, 1900, ch. 339</ref>, § 4, <ref href="/us/stat/31/141">31 Stat. 141</ref>. See <ref href="/us/usc/t8/s1405">section 1405 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ada-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 5 and 5a, relating to citizenship of Puerto Ricans, were from <ref href="/us/act/1917-03-02/ch145">act Mar. 2, 1917, ch. 145</ref>, §§ 5, 5a, respectively, <ref href="/us/stat/39/953">39 Stat. 953</ref>, as amended <ref href="/us/act/1927-03-04/ch503">Mar. 4, 1927, ch. 503</ref>, § 2, <ref href="/us/stat/44/1418">44 Stat. 1418</ref>; <ref href="/us/act/1932-05-17/ch190">May 17, 1932, ch. 190</ref>, <ref href="/us/stat/47/158">47 Stat. 158</ref>. See <ref href="/us/usc/t8/s1402">section 1402 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144adb-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 5a–1, making a further extension of time for Puerto Ricans to become citizens in cases of misinformation regarding status, was repealed by <ref href="/us/act/1940-10-14/ch876/tI">act Oct. 14, 1940, ch. 876, title I</ref>, subch. V, § 504, <ref href="/us/stat/54/1174">54 Stat. 1174</ref>. It was from <ref href="/us/act/1938-05-16/ch225">act May 16, 1938, ch. 225</ref>, <ref href="/us/stat/52/377">52 Stat. 377</ref>. See <ref href="/us/usc/t8/s1402">section 1402 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144adc-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 5b and 5c, relating to citizenship of inhabitants of the Virgin Islands, were from <ref href="/us/act/1927-02-25/ch192">act Feb. 25, 1927, ch. 192</ref>, §§ 1, 3, respectively, <ref href="/us/stat/44/1234">44 Stat. 1234</ref>, 1235, as amended <ref href="/us/act/1932-05-17/ch190">May 17, 1932, ch. 190</ref>, <ref href="/us/stat/47/158">47 Stat. 158</ref>; <ref href="/us/act/1932-06-28/ch283">June 28, 1932, ch. 283</ref>, § 5, <ref href="/us/stat/47/336">47 Stat. 336</ref>. See <ref href="/us/usc/t8/s1406">section 1406 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144add-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 5d to 9a were repealed by <ref href="/us/act/1940-10-14/ch876/tI">act Oct. 14, 1940, ch. 876, title I</ref>, subch. V, § 504, <ref href="/us/stat/54/1174">54 Stat. 1174</ref>. Sections 5d and 5e, relating to citizenship of persons born in Canal Zone or Panama, were from <ref href="/us/act/1937-08-04/ch563">act Aug. 4, 1937, ch. 563</ref>, §§ 1, 2, respectively, <ref href="/us/stat/50/558">50 Stat. 558</ref>; see <ref href="/us/usc/t8/s1403">section 1403 of this title</ref>. Section 6, relating to citizenship of children born outside the United States, was from R.S. § 1993 (revised from acts <ref href="/us/act/1802-04-14/ch28">Apr. 14, 1802, ch. 28</ref>, § 4, <ref href="/us/stat/2/155">2 Stat. 155</ref>; <ref href="/us/act/1855-02-10/ch71">Feb. 10, 1855, ch. 71</ref>, § 1, <ref href="/us/stat/10/604">10 Stat. 604</ref>); <ref href="/us/act/1907-03-02/ch2534">act Mar. 2, 1907, ch. 2534</ref>, §§ 6, 7, <ref href="/us/stat/34/1229">34 Stat. 1229</ref>, as amended <ref href="/us/act/1934-05-24/ch344">May 24, 1934, ch. 344</ref>, § 1, <ref href="/us/stat/48/797">48 Stat. 797</ref>; see sections 1431 to 1433 of this title. Section 7, relating to citizenship of children of persons naturalized under certain laws, was from R.S. § 2172, which was revised from <ref href="/us/act/1802-04-14/ch28">act Apr. 14, 1802, ch. 28</ref>, § 4, <ref href="/us/stat/2/155">2 Stat. 155</ref>. Section 8, relating to citizenship, upon parent’s naturalization, of children born abroad of alien parents, was from <ref href="/us/act/1907-03-02/ch2534">act Mar. 2, 1907, ch. 2534</ref>, § 5, <ref href="/us/stat/34/1229">34 Stat. 1229</ref>, as amended <ref href="/us/act/1934-05-24/ch344">May 24, 1934, ch. 344</ref>, § 2, <ref href="/us/stat/48/797">48 Stat. 797</ref>. Section 9, relating to citizenship of women citizens as affected by marriage, was from acts <ref href="/us/act/1922-09-22/ch411">Sept. 22, 1922, ch. 411</ref>, § 3(a), <ref href="/us/stat/42/1022">42 Stat. 1022</ref>; <ref href="/us/act/1930-07-03/ch835">July 3, 1930, ch. 835</ref>, § 1, <ref href="/us/stat/46/854">46 Stat. 854</ref>; <ref href="/us/act/1931-03-03/ch442">Mar. 3, 1931, ch. 442</ref>, § 4(a), <ref href="/us/stat/46/1511">46 Stat. 1511</ref>; see <ref href="/us/usc/t8/s1435">section 1435 of this title</ref>. Section 9a, relating to repatriation of native-born women married to aliens prior to <date date="1922-09-22">Sept. 22, 1922</date>, was from <ref href="/us/act/1936-06-25/ch801">act June 25, 1936, ch. 801</ref>, <ref href="/us/stat/49/1917">49 Stat. 1917</ref>, as amended <ref href="/us/act/1940-07-02/ch509">July 2, 1940, ch. 509</ref>, <ref href="/us/stat/54/715">54 Stat. 715</ref>; see <ref href="/us/usc/t8/s1435/c">section 1435(c) of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ade-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 10, relating to effect of certain repeals on citizenship of women marrying citizens, was from <ref href="/us/act/1922-09-22/ch411">act Sept. 22, 1922, ch. 411</ref>, § 6, <ref href="/us/stat/42/1022">42 Stat. 1022</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144adf-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 11 and 12, relating to forfeiture of citizenship for desertion from armed forces, were repealed by acts <ref href="/us/act/1956-08-10/ch1041">Aug. 10, 1956, ch. 1041</ref>, § 53, <ref href="/us/stat/70A/644">70A Stat. 644</ref>, and <date date="1966-09-06">Sept. 6, 1966</date>, <ref href="/us/pl/89/554">Pub. L. 89–554</ref>, § 8, <ref href="/us/stat/80/632">80 Stat. 632</ref>. Section 11 was from R.S. § 1998 (revised from <ref href="/us/act/1865-03-03/ch79">act Mar. 3, 1865, ch. 79</ref>, § 21, <ref href="/us/stat/13/490">13 Stat. 490</ref>) as amended by acts <ref href="/us/act/1912-08-22/ch336">Aug. 22, 1912, ch. 336</ref>, § 1, <ref href="/us/stat/37/356">37 Stat. 356</ref>; <ref href="/us/act/1940-10-14/ch876">Oct. 14, 1940, ch. 876</ref>, title I, subch. V, § 504, <ref href="/us/stat/54/1172">54 Stat. 1172</ref>. Section 12 was from R.S. §§ 1996, 1997, which were revised from acts <ref href="/us/act/1865-03-03/ch79">Mar. 3, 1865, ch. 79</ref>, § 21, <ref href="/us/stat/13/490">13 Stat. 490</ref>, and <ref href="/us/act/1867-07-19/ch28">July 19, 1867, ch. 28</ref>, <ref href="/us/stat/15/14">15 Stat. 14</ref>, respectively; see sections 1481 and 1483 of this title.</p>
            </note>
            <note topic="removalDescription" id="ida3144ae0-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 13 and 14, relating to protection of citizens when abroad, were transferred to sections 1731 and 1732 of Title 22, Foreign Relations and Intercourse.</p>
            </note>
            <note topic="removalDescription" id="ida3144ae1-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 15, R.S. § 1999, which relates to right of expatriation, is now set out as a note under <ref href="/us/usc/t8/s1481">section 1481 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ae2-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 16 to 18, relating to loss of citizenship, were repealed by <ref href="/us/act/1940-10-14/ch876/tI">act Oct. 14, 1940, ch. 876, title I</ref>, subch. V, § 504, <ref href="/us/stat/54/1172">54 Stat. 1172</ref>. Section 16 was from <ref href="/us/act/1907-03-02/ch2534">act Mar. 2, 1907, ch. 2534</ref>, § 2, <ref href="/us/stat/34/1228">34 Stat. 1228</ref>. Section 17 was from <ref href="/us/act/1907-03-02/ch2534">act Mar. 2, 1907, ch. 2534</ref>, §§ 2, 7, <ref href="/us/stat/34/1228">34 Stat. 1228</ref>, 1229; see sections 1481(a), 1482 and 1484 of this title. Section 17a was from <ref href="/us/act/1934-05-24/ch344">act May 24, 1934, ch. 344</ref>, § 3, <ref href="/us/stat/48/797">48 Stat. 797</ref>; see <ref href="/us/usc/t8/s1481/a">section 1481(a) of this title</ref>. Section 18 was from acts <ref href="/us/act/1906-06-29/ch3592">June 29, 1906, ch. 3592</ref>, § 4(12), <ref href="/us/stat/34/596">34 Stat. 596</ref>; <ref href="/us/act/1918-05-09/ch69">May 9, 1918, ch. 69</ref>, § 1, <ref href="/us/stat/40/545">40 Stat. 545</ref>; <ref href="/us/act/1930-06-21/ch559">June 21, 1930, ch. 559</ref>, <ref href="/us/stat/46/791">46 Stat. 791</ref>; see sections 1438(a), 1454, 1455, and 1459 of this title.</p>
            </note>
          </notes>
        </section>
      </chapter>
     
    </title>
  </main>'

  select
  tbl.col.value('note[1]', 'varchar(max)')
 
FROM   @xml.nodes('/main/title/chapter/section/notes') tbl(col)

Open in new window


This one doesn't work. I think I don't have the path correct

declare @xml XML

--select @xml = xmlcol from ImmigrationXML

set @xml ='<?xml-stylesheet type="text/css" href="usctitle.css"?>
<uscDoc xmlns="http://xml.house.gov/schemas/uslm/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xsi:schemaLocation="http://xml.house.gov/schemas/uslm/1.0 USLM-1.0.15.xsd" xml:lang="en" identifier="/us/usc/t8">
  <meta>
    <dc:title>Title 8</dc:title>
    <dc:type>USCTitle</dc:type>
    <docNumber>8</docNumber>
    <docPublicationName>Online@115-18</docPublicationName>
    <dc:publisher>OLRC</dc:publisher>
    <dcterms:created>2017-03-07T05:01:34</dcterms:created>
    <dc:creator>USCConverter 1.1</dc:creator>
  </meta>
  <main>
    <title id="ida3144ace-0381-11e7-859c-c7e65b0ded31" identifier="/us/usc/t8">
      <num value="8">Title 8—</num>
      <heading>ALIENS AND NATIONALITY</heading>
      <note topic="miscellaneous" id="ida3144acf-0381-11e7-859c-c7e65b0ded31">
        <p>Current through 115-18</p>
      </note>
      <toc role="threeColumnTOC" id="ida3144ad0-0381-11e7-859c-c7e65b0ded31">
        <layout>
          <header style="-uslm-lc:I70" role="tocColumnHeader">
            <column class="tocHeaderLeft">Chap.</column>
            <column />
            <column style="-uslm-lc:I29" class="tocHeaderRight">Sec.</column>
          </header>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch1">1.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">General Provisions [Repealed or Omitted]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1">1</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch2">2.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Elective Franchise [Transferred]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s31">31</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch3">3.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Civil Rights [Transferred or Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s41">41</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch4">4.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Freedmen [Omitted]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s61">61</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch5">5.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Alien Ownership of Land [Transferred or Omitted]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s71">71</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch6">6.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Immigration [Transferred, Omitted, or Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s100">100</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch7">7.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Exclusion of Chinese [Omitted or Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s261">261</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch8">8.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">The Cooly Trade [Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s331">331</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch9">9.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Miscellaneous Provisions [Repealed or Transferred]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s351">351</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch10">10.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Alien Registration [Repealed]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s451">451</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch11">11.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Nationality [Repealed or Transferred]</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s501">501</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch12">12.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Immigration and Nationality</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1101">1101</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch13">13.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Immigration and Naturalization Service</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1551">1551</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch14">14.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Restricting Welfare and Public Benefits for Aliens</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1601">1601</ref>
            </column>
          </tocItem>
          <tocItem>
            <column style="-uslm-lc:I07" class="threeColumnLeft">
              <ref href="/us/usc/t8/ch15">15.</ref>
            </column>
            <column style="-uslm-lc:I08" class="threeColumnMiddle">Enhanced Border Security and Visa Entry Reform</column>
            <column style="-uslm-lc:I09" class="threeColumnRight">
              <ref href="/us/usc/t8/s1701">1701</ref>
            </column>
          </tocItem>
        </layout>
      </toc>
      <chapter style="-uslm-lc:I81" id="ida3144ad1-0381-11e7-859c-c7e65b0ded31" identifier="/us/usc/t8/ch1">
        <num value="1">CHAPTER 1—</num>
        <heading>GENERAL PROVISIONS</heading>
        <section status="repealed" style="-uslm-lc:I80" id="ida3144ad2-0381-11e7-859c-c7e65b0ded31" identifier="/us/usc/t8/s1...18">
          <num value="1 to 18">§§ 1 to 18.</num>
          <heading> Repealed or Omitted</heading>
          <notes type="uscNote" id="ida3144ad3-0381-11e7-859c-c7e65b0ded31">
            <note topic="removalDescription" id="ida3144ad4-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">These sections, relating to citizenship, were affected by the Nationality Act of 1940, former section 501 et seq. of this title.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad5-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">That act was passed on <date date="1940-10-14">Oct. 14, 1940</date>, to consolidate and restate the laws of the United States regarding citizenship, naturalization, and expatriation, and, in addition to certain specific repeals thereby, all acts or parts of acts in conflict with its provisions were repealed by former <ref href="/us/usc/t8/s904">section 904 of this title</ref>. See the notes below for history of individual sections.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad6-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 1, relating to citizenship of persons born in the United States, was repealed by <ref href="/us/act/1940-10-14/ch876/tI">act Oct. 14, 1940, ch. 876, title I</ref>, subch. V, § 504, <ref href="/us/stat/54/1172">54 Stat. 1172</ref>. It was from R.S. § 1992, which was revised from <ref href="/us/act/1866-04-09/ch31">act Apr. 9, 1866, ch. 31</ref>, § 1, <ref href="/us/stat/14/27">14 Stat. 27</ref>. Similar provisions were contained in former <ref href="/us/usc/t8/s601/a">section 601(a) of this title</ref>. See <ref href="/us/usc/t8/s1401">section 1401 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad7-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 2, relating to citizenship of persons born in Territory of Oregon, was from R.S. § 1995, which was revised from <ref href="/us/act/1872-05-18/ch172">act May 18, 1872, ch. 172</ref>, § 3, <ref href="/us/stat/17/134">17 Stat. 134</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad8-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 3 to 3c, related to citizenship of Indians. Section 3 was from acts <ref href="/us/act/1887-02-08/ch119">Feb. 8, 1887, ch. 119</ref>, § 6, <ref href="/us/stat/24/390">24 Stat. 390</ref>; <ref href="/us/act/1901-03-03/ch868">Mar. 3, 1901, ch. 868</ref>, <ref href="/us/stat/31/1447">31 Stat. 1447</ref>; <ref href="/us/act/1906-05-08/ch2348">May 8, 1906, ch. 2348</ref>, <ref href="/us/stat/34/182">34 Stat. 182</ref>; <ref href="/us/act/1919-11-06/ch95">Nov. 6, 1919, ch. 95</ref>, <ref href="/us/stat/41/350">41 Stat. 350</ref>; <ref href="/us/act/1921-03-03/ch120">Mar. 3, 1921, ch. 120</ref>, § 3, <ref href="/us/stat/41/1250">41 Stat. 1250</ref>; <ref href="/us/act/1924-06-02/ch233">June 2, 1924, ch. 233</ref>, <ref href="/us/stat/43/253">43 Stat. 253</ref>; <ref href="/us/act/1940-10-14/ch876">Oct. 14, 1940, ch. 876</ref>, title I, subch. V, § 504, <ref href="/us/stat/54/1173">54 Stat. 1173</ref>. Section 3a was from <ref href="/us/act/1930-06-19/ch544">act June 19, 1930, ch. 544</ref>, <ref href="/us/stat/46/787">46 Stat. 787</ref>. Section 3b was from acts <ref href="/us/act/1934-05-07/ch221">May 7, 1934, ch. 221</ref>, § 1, <ref href="/us/stat/48/667">48 Stat. 667</ref>; <ref href="/us/act/1947-07-23/ch304">July 23, 1947, ch. 304</ref>, § 1, <ref href="/us/stat/61/414">61 Stat. 414</ref>. Section 3c was from <ref href="/us/act/1934-05-07/ch221">act May 7, 1934, ch. 221</ref>, § 2, <ref href="/us/stat/48/667">48 Stat. 667</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ad9-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 4, relating to citizenship of Hawaiians, was from <ref href="/us/act/1900-04-30/ch339">act Apr. 30, 1900, ch. 339</ref>, § 4, <ref href="/us/stat/31/141">31 Stat. 141</ref>. See <ref href="/us/usc/t8/s1405">section 1405 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ada-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 5 and 5a, relating to citizenship of Puerto Ricans, were from <ref href="/us/act/1917-03-02/ch145">act Mar. 2, 1917, ch. 145</ref>, §§ 5, 5a, respectively, <ref href="/us/stat/39/953">39 Stat. 953</ref>, as amended <ref href="/us/act/1927-03-04/ch503">Mar. 4, 1927, ch. 503</ref>, § 2, <ref href="/us/stat/44/1418">44 Stat. 1418</ref>; <ref href="/us/act/1932-05-17/ch190">May 17, 1932, ch. 190</ref>, <ref href="/us/stat/47/158">47 Stat. 158</ref>. See <ref href="/us/usc/t8/s1402">section 1402 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144adb-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 5a–1, making a further extension of time for Puerto Ricans to become citizens in cases of misinformation regarding status, was repealed by <ref href="/us/act/1940-10-14/ch876/tI">act Oct. 14, 1940, ch. 876, title I</ref>, subch. V, § 504, <ref href="/us/stat/54/1174">54 Stat. 1174</ref>. It was from <ref href="/us/act/1938-05-16/ch225">act May 16, 1938, ch. 225</ref>, <ref href="/us/stat/52/377">52 Stat. 377</ref>. See <ref href="/us/usc/t8/s1402">section 1402 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144adc-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 5b and 5c, relating to citizenship of inhabitants of the Virgin Islands, were from <ref href="/us/act/1927-02-25/ch192">act Feb. 25, 1927, ch. 192</ref>, §§ 1, 3, respectively, <ref href="/us/stat/44/1234">44 Stat. 1234</ref>, 1235, as amended <ref href="/us/act/1932-05-17/ch190">May 17, 1932, ch. 190</ref>, <ref href="/us/stat/47/158">47 Stat. 158</ref>; <ref href="/us/act/1932-06-28/ch283">June 28, 1932, ch. 283</ref>, § 5, <ref href="/us/stat/47/336">47 Stat. 336</ref>. See <ref href="/us/usc/t8/s1406">section 1406 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144add-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 5d to 9a were repealed by <ref href="/us/act/1940-10-14/ch876/tI">act Oct. 14, 1940, ch. 876, title I</ref>, subch. V, § 504, <ref href="/us/stat/54/1174">54 Stat. 1174</ref>. Sections 5d and 5e, relating to citizenship of persons born in Canal Zone or Panama, were from <ref href="/us/act/1937-08-04/ch563">act Aug. 4, 1937, ch. 563</ref>, §§ 1, 2, respectively, <ref href="/us/stat/50/558">50 Stat. 558</ref>; see <ref href="/us/usc/t8/s1403">section 1403 of this title</ref>. Section 6, relating to citizenship of children born outside the United States, was from R.S. § 1993 (revised from acts <ref href="/us/act/1802-04-14/ch28">Apr. 14, 1802, ch. 28</ref>, § 4, <ref href="/us/stat/2/155">2 Stat. 155</ref>; <ref href="/us/act/1855-02-10/ch71">Feb. 10, 1855, ch. 71</ref>, § 1, <ref href="/us/stat/10/604">10 Stat. 604</ref>); <ref href="/us/act/1907-03-02/ch2534">act Mar. 2, 1907, ch. 2534</ref>, §§ 6, 7, <ref href="/us/stat/34/1229">34 Stat. 1229</ref>, as amended <ref href="/us/act/1934-05-24/ch344">May 24, 1934, ch. 344</ref>, § 1, <ref href="/us/stat/48/797">48 Stat. 797</ref>; see sections 1431 to 1433 of this title. Section 7, relating to citizenship of children of persons naturalized under certain laws, was from R.S. § 2172, which was revised from <ref href="/us/act/1802-04-14/ch28">act Apr. 14, 1802, ch. 28</ref>, § 4, <ref href="/us/stat/2/155">2 Stat. 155</ref>. Section 8, relating to citizenship, upon parent’s naturalization, of children born abroad of alien parents, was from <ref href="/us/act/1907-03-02/ch2534">act Mar. 2, 1907, ch. 2534</ref>, § 5, <ref href="/us/stat/34/1229">34 Stat. 1229</ref>, as amended <ref href="/us/act/1934-05-24/ch344">May 24, 1934, ch. 344</ref>, § 2, <ref href="/us/stat/48/797">48 Stat. 797</ref>. Section 9, relating to citizenship of women citizens as affected by marriage, was from acts <ref href="/us/act/1922-09-22/ch411">Sept. 22, 1922, ch. 411</ref>, § 3(a), <ref href="/us/stat/42/1022">42 Stat. 1022</ref>; <ref href="/us/act/1930-07-03/ch835">July 3, 1930, ch. 835</ref>, § 1, <ref href="/us/stat/46/854">46 Stat. 854</ref>; <ref href="/us/act/1931-03-03/ch442">Mar. 3, 1931, ch. 442</ref>, § 4(a), <ref href="/us/stat/46/1511">46 Stat. 1511</ref>; see <ref href="/us/usc/t8/s1435">section 1435 of this title</ref>. Section 9a, relating to repatriation of native-born women married to aliens prior to <date date="1922-09-22">Sept. 22, 1922</date>, was from <ref href="/us/act/1936-06-25/ch801">act June 25, 1936, ch. 801</ref>, <ref href="/us/stat/49/1917">49 Stat. 1917</ref>, as amended <ref href="/us/act/1940-07-02/ch509">July 2, 1940, ch. 509</ref>, <ref href="/us/stat/54/715">54 Stat. 715</ref>; see <ref href="/us/usc/t8/s1435/c">section 1435(c) of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ade-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 10, relating to effect of certain repeals on citizenship of women marrying citizens, was from <ref href="/us/act/1922-09-22/ch411">act Sept. 22, 1922, ch. 411</ref>, § 6, <ref href="/us/stat/42/1022">42 Stat. 1022</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144adf-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 11 and 12, relating to forfeiture of citizenship for desertion from armed forces, were repealed by acts <ref href="/us/act/1956-08-10/ch1041">Aug. 10, 1956, ch. 1041</ref>, § 53, <ref href="/us/stat/70A/644">70A Stat. 644</ref>, and <date date="1966-09-06">Sept. 6, 1966</date>, <ref href="/us/pl/89/554">Pub. L. 89–554</ref>, § 8, <ref href="/us/stat/80/632">80 Stat. 632</ref>. Section 11 was from R.S. § 1998 (revised from <ref href="/us/act/1865-03-03/ch79">act Mar. 3, 1865, ch. 79</ref>, § 21, <ref href="/us/stat/13/490">13 Stat. 490</ref>) as amended by acts <ref href="/us/act/1912-08-22/ch336">Aug. 22, 1912, ch. 336</ref>, § 1, <ref href="/us/stat/37/356">37 Stat. 356</ref>; <ref href="/us/act/1940-10-14/ch876">Oct. 14, 1940, ch. 876</ref>, title I, subch. V, § 504, <ref href="/us/stat/54/1172">54 Stat. 1172</ref>. Section 12 was from R.S. §§ 1996, 1997, which were revised from acts <ref href="/us/act/1865-03-03/ch79">Mar. 3, 1865, ch. 79</ref>, § 21, <ref href="/us/stat/13/490">13 Stat. 490</ref>, and <ref href="/us/act/1867-07-19/ch28">July 19, 1867, ch. 28</ref>, <ref href="/us/stat/15/14">15 Stat. 14</ref>, respectively; see sections 1481 and 1483 of this title.</p>
            </note>
            <note topic="removalDescription" id="ida3144ae0-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 13 and 14, relating to protection of citizens when abroad, were transferred to sections 1731 and 1732 of Title 22, Foreign Relations and Intercourse.</p>
            </note>
            <note topic="removalDescription" id="ida3144ae1-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Section 15, R.S. § 1999, which relates to right of expatriation, is now set out as a note under <ref href="/us/usc/t8/s1481">section 1481 of this title</ref>.</p>
            </note>
            <note topic="removalDescription" id="ida3144ae2-0381-11e7-859c-c7e65b0ded31">
              <p style="-uslm-lc:I21" class="indent0">Sections 16 to 18, relating to loss of citizenship, were repealed by <ref href="/us/act/1940-10-14/ch876/tI">act Oct. 14, 1940, ch. 876, title I</ref>, subch. V, § 504, <ref href="/us/stat/54/1172">54 Stat. 1172</ref>. Section 16 was from <ref href="/us/act/1907-03-02/ch2534">act Mar. 2, 1907, ch. 2534</ref>, § 2, <ref href="/us/stat/34/1228">34 Stat. 1228</ref>. Section 17 was from <ref href="/us/act/1907-03-02/ch2534">act Mar. 2, 1907, ch. 2534</ref>, §§ 2, 7, <ref href="/us/stat/34/1228">34 Stat. 1228</ref>, 1229; see sections 1481(a), 1482 and 1484 of this title. Section 17a was from <ref href="/us/act/1934-05-24/ch344">act May 24, 1934, ch. 344</ref>, § 3, <ref href="/us/stat/48/797">48 Stat. 797</ref>; see <ref href="/us/usc/t8/s1481/a">section 1481(a) of this title</ref>. Section 18 was from acts <ref href="/us/act/1906-06-29/ch3592">June 29, 1906, ch. 3592</ref>, § 4(12), <ref href="/us/stat/34/596">34 Stat. 596</ref>; <ref href="/us/act/1918-05-09/ch69">May 9, 1918, ch. 69</ref>, § 1, <ref href="/us/stat/40/545">40 Stat. 545</ref>; <ref href="/us/act/1930-06-21/ch559">June 21, 1930, ch. 559</ref>, <ref href="/us/stat/46/791">46 Stat. 791</ref>; see sections 1438(a), 1454, 1455, and 1459 of this title.</p>
            </note>
          </notes>
        </section>
      </chapter>
     
    </title>
  </main>
</uscDoc>'

   SELECT
tbl.col.value('note[1]', 'varchar(max)')
 
FROM   @xml.nodes('/uscDoc/main/title/chapter/section/notes') tbl(col)

Open in new window

Avatar of HainKurt
HainKurt
Flag of Canada image

what do you get?

empty result or error? if error, what is it?
Avatar of Camillia

ASKER

Empty. You can run it.
;with XMLNAMESPACES (DEFAULT 'http://xml.house.gov/schemas/uslm/1.0') 
SELECT tbl.col.value('note[1]', 'varchar(max)') 
FROM   @xml.nodes('/uscDoc/main/title/chapter/section/notes') tbl(col)

Open in new window

I get Must declare the scalar variable "@xml". error.

This ;with XMLNAMESPACES (DEFAULT 'http://xml.house.gov/schemas/uslm/1.0')   needs to be assigned to @xml, I think?
I've requested that this question be deleted for the following reason:

The solution doesn't work. I'll just delete the top part and use my workaround

<?xml-stylesheet type="text/css" href="usctitle.css"?>
<uscDoc xmlns="http://xml.house.gov/schemas/uslm/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xsi:schemaLocation="http://xml.house.gov/schemas/uslm/1.0 USLM-1.0.15.xsd" xml:lang="en" identifier="/us/usc/t8">
  <meta>
    <dc:title>Title 8</dc:title>
    <dc:type>USCTitle</dc:type>
    <docNumber>8</docNumber>
    <docPublicationName>Online@115-18</docPublicationName>
    <dc:publisher>OLRC</dc:publisher>
    <dcterms:created>2017-03-07T05:01:34</dcterms:created>
    <dc:creator>USCConverter 1.1</dc:creator>
  </meta>
it works!

if you say

"I get Must declare the scalar variable "@xml". error." then you should use

declare @xml XML

which is already in your original post...
then

;with XMLNAMESPACES (DEFAULT 'http://xml.house.gov/schemas/uslm/1.0') 
SELECT tbl.col.value('note[1]', 'varchar(max)') 
FROM   @xml.nodes('/uscDoc/main/title/chapter/section/notes') tbl(col)

Open in new window


gives the data that you need!
I still don't get any results back

declare @xml XML

;with XMLNAMESPACES (DEFAULT 'http://xml.house.gov/schemas/uslm/1.0') 
SELECT tbl.col.value('note[1]', 'varchar(max)') 
FROM   @xml.nodes('/uscDoc/main/title/chapter/section/notes') tbl(col)

Open in new window

declare @xml XML

>>> where is your statement that sets xml? Line 5-225 in your org post, second code area

;with XMLNAMESPACES (DEFAULT 'http://xml.house.gov/schemas/uslm/1.0')
SELECT tbl.col.value('note[1]', 'varchar(max)')
FROM   @xml.nodes('/uscDoc/main/title/chapter/section/notes') tbl(col)
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial