<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=14805&amp;type=atom" />
	<updated>2019-06-04T12:29:39Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=14805</id>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134622#p134622" />
			<content type="html"><![CDATA[<p>По аналогии с тем, что выше. Чтобы прочитать значение <em>name</em>, используется метод <em>getAttribute()</em>:<br /></p><div class="codebox"><pre><code>filePath := A_Desktop . &quot;\test.xml&quot; ; указать путь к файлу

xmlDoc := ComObjCreate(&quot;Microsoft.XMLDOM&quot;)

if !xmlDoc.load(filePath) {
   MsgBox, Не удалось загрузить документ
   Return
}

coll := xmlDoc.getElementsByTagName(&quot;offer&quot;)
if !coll.Length {
   MsgBox, Теги &lt;offer&gt; не найдены
   Return
}

for item in coll {
   param := item.getElementsByTagName(&quot;param&quot;).(0)
   MsgBox, % name := param.getAttribute(&quot;name&quot;)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-06-04T12:29:39Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134622#p134622</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134618#p134618" />
			<content type="html"><![CDATA[<p>&lt;offers&gt;<br />&lt;offer available=&quot;true&quot; id=&quot;770448733&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt; Тара 10 &lt;/name&gt;<br />	&lt;vendor&gt; Тара 10 &lt;/vendor&gt;<br />&nbsp; &nbsp; &lt;param name=&quot;Габариты:&quot; unit=&quot;&quot;&gt;160x200x300 мм&lt;/param&gt;<br />&nbsp; &lt;/offer&gt;</p><p>&nbsp; &lt;offer available=&quot;true&quot; id=&quot;793606558&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt; Тара 20 &lt;/name&gt;<br />	&lt;vendor&gt; Тара 20 &lt;/vendor&gt;<br />	&lt;param name=&quot;Габариты:&quot; unit=&quot;&quot;&gt;500x900x600 мм&lt;/param&gt;<br />&nbsp; &nbsp; &lt;/offer&gt;<br />&lt;/offers&gt;</p><p>Подскажите, как сделать скрипт для копирования каждого отдельного параметра &lt;offer&gt;, каждого отдельного значения параметра &quot;Габариты&quot;, чтоб оно стояло в поле &lt;vendor&gt;, после названия товара?</p><p>Пример - как должно быть:</p><p>&lt;offers&gt;<br />&lt;offer available=&quot;true&quot; id=&quot;770448733&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt; Тара 10 &lt;/name&gt;<br />	&lt;vendor&gt; Тара 10 160x200x300 мм&lt;/vendor&gt;<br />&nbsp; &nbsp; &lt;param name=&quot;Габариты:&quot; unit=&quot;&quot;&gt;160x200x300 мм&lt;/param&gt;<br />&nbsp; &lt;/offer&gt;</p><p>&nbsp; &lt;offer available=&quot;true&quot; id=&quot;793606558&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt; Тара 20 &lt;/name&gt;<br />	&lt;vendor&gt; Тара 20 500x900x600 мм&lt;/vendor&gt;<br />	&lt;param name=&quot;Габариты:&quot; unit=&quot;&quot;&gt;500x900x600 мм&lt;/param&gt;<br />&nbsp; &nbsp; &lt;/offer&gt;<br />&lt;/offers&gt;</p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-06-04T08:30:49Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134618#p134618</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134574#p134574" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> Функционирует.</p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-05-30T17:27:48Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134574#p134574</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134571#p134571" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>filePath := &quot;C:\Users\User\Desktop\Test.xml&quot; ; указать путь к файлу

xmlDoc := ComObjCreate(&quot;Microsoft.XMLDOM&quot;)

if !xmlDoc.load(filePath) {
   MsgBox, Не удалось загрузить документ
   Return
}

coll := xmlDoc.getElementsByTagName(&quot;offer&quot;)
if !coll.Length {
   MsgBox, Теги &lt;offer&gt; не найдены
   Return
}

for item in coll {
   vendor2 := item.getElementsByTagName(&quot;vendor&quot;).(1)
   vendor2.parentNode.removeChild(vendor2)
}

xmlDoc.Save(filePath)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-05-30T16:50:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134571#p134571</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134555#p134555" />
			<content type="html"><![CDATA[<p>Если уж тут речь идёт исключительно об AHK, отредактируйте заголовок топика так, чтобы он соответствовал его содержанию. Это нужно для того, чтобы тем, кто столкнулся с подобными задачами, было легче найти ответ на форуме.<br />Для оформления кода используйте соответствующий <a href="http://forum.script-coding.com/help.php?section=bbcode">тег</a>.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-05-30T13:00:26Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134555#p134555</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134554#p134554" />
			<content type="html"><![CDATA[<p>&lt;offers&gt;<br />&lt;offer available=&quot;true&quot; id=&quot;770448733&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt; Тара 10&lt;/name&gt;<br />	&lt;vendor&gt;Тара 10&lt;/vendor&gt;<br />&nbsp; &nbsp; &lt;vendor&gt;лоижло&lt;/vendor&gt; <br />&nbsp; &lt;/offer&gt;</p><p>&nbsp; &lt;offer available=&quot;true&quot; id=&quot;793606558&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt;Тара 20&lt;/name&gt;<br />	&lt;vendor&gt;Тара 20&lt;/vendor&gt;<br />&nbsp; &nbsp; &lt;vendor&gt;алоплфдаоп&lt;/vendor&gt;<br />&nbsp; &lt;/offer&gt;<br />&lt;/offers&gt;</p><p>Как сделать AHK, для того чтоб в каждом &lt;offer&gt; удалить второй &lt;vendor&gt;?</p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-05-30T12:20:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134554#p134554</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134550#p134550" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> Функционирует.</p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-05-29T22:09:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134550#p134550</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134549#p134549" />
			<content type="html"><![CDATA[<p>На сайте AHK, сохранять нужно в UTF-8.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-05-29T22:07:00Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134549#p134549</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134548#p134548" />
			<content type="html"><![CDATA[<p>Может не в UTF-8 сохранять файл?</p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-05-29T21:55:30Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134548#p134548</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134547#p134547" />
			<content type="html"><![CDATA[<p>AHK 1.1.30.3 Unicode 64 - где взять?</p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-05-29T21:53:40Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134547#p134547</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134546#p134546" />
			<content type="html"><![CDATA[<p>У меня работает:</p><p><span class="postimg"><img src="https://i.imgur.com/xiOu9iP.png" alt="https://i.imgur.com/xiOu9iP.png" /></span></p><div class="codebox"><pre><code>filePath := &quot;C:\Users\User\Desktop\Test.xml&quot; ; указать путь к файлу

xmlDoc := ComObjCreate(&quot;Microsoft.XMLDOM&quot;)

if !xmlDoc.load(filePath) {
   MsgBox, Не удалось загрузить документ
   Return
}

coll := xmlDoc.getElementsByTagName(&quot;offer&quot;)
if !coll.Length {
   MsgBox, Теги &lt;offer&gt; не найдены
   Return
}

for item in coll {
   nameText := item.getElementsByTagName(&quot;name&quot;).(0).text
   item.getElementsByTagName(&quot;vendor&quot;).(0).text := nameText
}

xmlDoc.Save(filePath)</code></pre></div><p>Проверял на Windows 7 64, AHK 1.1.30.3 Unicode 64</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-05-29T21:46:53Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134546#p134546</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134545#p134545" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> Мне надо из такого:</p><p>&lt;offers&gt;<br />&lt;offer available=&quot;true&quot; id=&quot;770448733&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt; Тара 10&lt;/name&gt;<br />&nbsp; &nbsp; &lt;vendor&gt;лоижло&lt;/vendor&gt;&nbsp; <br />&nbsp; &lt;/offer&gt;</p><p>&nbsp; &lt;offer available=&quot;true&quot; id=&quot;793606558&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt;Тара 20&lt;/name&gt;<br />&nbsp; &nbsp; &lt;vendor&gt;алоплфдаоп&lt;/vendor&gt;<br />&nbsp; &lt;/offer&gt;<br />&lt;/offers&gt;</p><p>Получить такое:</p><p>&lt;offers&gt;<br />&lt;offer available=&quot;true&quot; id=&quot;770448733&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt; Тара 10&lt;/name&gt;<br />&nbsp; &nbsp; &lt;vendor&gt;Тара 10&lt;/vendor&gt;&nbsp; <br />&nbsp; &lt;/offer&gt;</p><p>&nbsp; &lt;offer available=&quot;true&quot; id=&quot;793606558&quot;&gt;<br />&nbsp; &nbsp; &lt;name&gt;Тара 20&lt;/name&gt;<br />&nbsp; &nbsp; &lt;vendor&gt;Тара 20&lt;/vendor&gt;<br />&nbsp; &lt;/offer&gt;<br />&lt;/offers&gt;</p><p>Что оно поменяло в каждом отдельном разделе &quot;offer&quot;.</p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-05-29T21:44:56Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134545#p134545</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134544#p134544" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong></p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-05-29T21:40:47Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134544#p134544</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134543#p134543" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong></p>]]></content>
			<author>
				<name><![CDATA[Creater3d]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40171</uri>
			</author>
			<updated>2019-05-29T21:39:38Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134543#p134543</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Как создать AHK для изменения xml-файла внутри или другие варианты?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=134540#p134540" />
			<content type="html"><![CDATA[<p>Что-то не так делаете, наверно. Скрипт (последняя версия) либо сообщение об ошибке должен выдать, либо всё в порядке. Присылайте ваш файл, можно к сообщению прицепить, проверим.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-05-29T21:17:03Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=134540#p134540</id>
		</entry>
</feed>
