<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBScript: Не удаляется нода из XML]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7367&amp;type=atom" />
	<updated>2012-07-18T16:39:51Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7367</id>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Не удаляется нода из XML]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61735#p61735" />
			<content type="html"><![CDATA[<p>Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[chilin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28318</uri>
			</author>
			<updated>2012-07-18T16:39:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61735#p61735</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Не удаляется нода из XML]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61728#p61728" />
			<content type="html"><![CDATA[<p>Вам нужно удалять узел из его родителя, а не из корневого узла.<br />Примерно так:<br /></p><div class="codebox"><pre><code>dim  oXml, xmlFile, oNodes1
  set oXml   = CreateObject(&quot;Microsoft.XMLDOM&quot;)
  oXml.async = false
  xmlFile    = &quot;example.xml&quot;
  xmlFile2    = &quot;example2.xml&quot;
  oXml.Load(xmlFile)
&#039;set oNodes1  = oXml.selectSingleNode(&quot;/datapack/impex/table[@id=&#039;00.00&#039;]&quot;)
&#039;  set oNodes1  = oXml.selectSingleNode(&quot;/&quot;)
  set oNodes1  = oXml.selectSingleNode(&quot;//test[@id=&#039;01.00&#039;]&quot;)
  if oNodes1 is nothing then
    WScript.echo(&quot;Такой ноды нет&quot;)
  else 
    if oNodes1.parentNode is nothing then
      WScript.echo(&quot;Нельзя удалить корневой узел&quot;)
    else
      oNodes1.parentNode.removeChild(oNodes1)
      oXml.save(xmlFile2)
      WScript.echo(&quot;Нода удалена&quot;)
    end if
  end if</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Spy00000]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27060</uri>
			</author>
			<updated>2012-07-18T14:19:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61728#p61728</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBScript: Не удаляется нода из XML]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61726#p61726" />
			<content type="html"><![CDATA[<p>xml: example.xml<br /></p><div class="codebox"><pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;datapack&gt;
  &lt;impex&gt;
    &lt;table id=&quot;00.00&quot;&gt;
      &lt;test id=&quot;01.00&quot;/&gt;
    &lt;/table&gt;
  &lt;/impex&gt;
&lt;/datapack&gt;</code></pre></div><p>Требуется удалить всю секцию &lt;table&gt;&lt;/table&gt; для ID=00.00<br /></p><div class="codebox"><pre><code>dim  oXml, xmlFile, oNodes1
  set oXml   = CreateObject(&quot;Microsoft.XMLDOM&quot;)
  oXml.async = false
  xmlFile    = &quot;example.xml&quot;
  oXml.Load(xmlFile)
  &#039;set oNodes1  = oXml.selectSingleNode(&quot;/datapack/impex/table[@id=&#039;00.00&#039;]&quot;)
  set oNodes1  = oXml.selectSingleNode(&quot;//table[@id=&#039;00.00&#039;]&quot;)
  if oNodes1 is nothing then
    WScript.echo(&quot;Такой ноды нет&quot;)
  else 
    oXml.documentElement.removeChild(oNodes1)
    oXml.save(xmlFile)
    WScript.echo(&quot;Нода удалена&quot;)
  end if</code></pre></div><p>В таком виде, removeChild выдаёт ошибку &quot;Параметрический Node не является дочерним...&quot;<br />Если из XML удалить одну из секций datapack или impex - удаление происходит.<br />Неужели removeChild работает только с не более чем двумя вложениями?</p>]]></content>
			<author>
				<name><![CDATA[chilin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28318</uri>
			</author>
			<updated>2012-07-18T13:28:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61726#p61726</id>
		</entry>
</feed>
