<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBS: пакетный парсинг XML]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=8487</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8487&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBS: пакетный парсинг XML».]]></description>
		<lastBuildDate>Thu, 18 Jul 2013 13:21:54 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBS: пакетный парсинг XML]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73881#p73881</link>
			<description><![CDATA[<p>PowerShell:<br /></p><div class="codebox"><pre><code>$oWebClient = New-Object System.Net.WebClient

&#039;192.168.1.1&#039;, &#039;192.168.1.5&#039;, &#039;192.168.1.15&#039;, &#039;192.168.1.50&#039; | `
    ForEach-Object -Process {
        if (Test-Connection -ComputerName $_ -Count 1 -Quiet) {
            $sSourceFile = &quot;http://$_/admin/spacfg.xml&quot;
            $sDestFile   = &quot;$env:temp&quot; + &quot;\spacfg.xml&quot;

            $oWebClient.DownloadFile($sSourceFile, $sDestFile)

            [xml]$oXml = Get-Content -Path $sDestFile

            $sName   = $oXml.SelectSingleNode(&quot;/flat-profile/Host_Name     [@group=&#039;Info/System_Information&#039;]&quot; ).&#039;#text&#039; + &#039;.&#039; + `
                       $oXml.SelectSingleNode(&quot;/flat-profile/Domain        [@group=&#039;Info/System_Information&#039;]&quot; ).&#039;#text&#039;
            $sIP     = $oXml.SelectSingleNode(&quot;/flat-profile/Current_IP    [@group=&#039;Info/System_Information&#039;]&quot; ).&#039;#text&#039;
            $sMAC    = $oXml.SelectSingleNode(&quot;/flat-profile/MAC_Address   [@group=&#039;Info/Product_Information&#039;]&quot;).&#039;#text&#039;
            $sSerial = $oXml.SelectSingleNode(&quot;/flat-profile/Serial_Number [@group=&#039;Info/Product_Information&#039;]&quot;).&#039;#text&#039;

            $sName, $sIP, $sMAC, $sSerial | Add-Content -Path &quot;C:\Песочница\021\Destination\Out.txt&quot; 
        }
    }</code></pre></div><p>VBScript — примерно так:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim strAddress


For Each strAddress In Array(&quot;192.168.1.1&quot;, &quot;192.168.1.5&quot;, &quot;192.168.1.15&quot;, &quot;192.168.1.50&quot;)
    If IsEnabled(strAddress) Then
        With WScript.CreateObject(&quot;MSXML2.DOMDocument&quot;)
            If .load(&quot;http://&quot; &amp; strAddress &amp; &quot;/admin/spacfg.xml&quot;) Then
                WScript.Echo .SelectSingleNode(&quot;/flat-profile/Host_Name     [@group=&#039;Info/System_Information&#039;]&quot; ).text &amp; &quot;.&quot; &amp; _
                             .SelectSingleNode(&quot;/flat-profile/Domain        [@group=&#039;Info/System_Information&#039;]&quot; ).text
                WScript.Echo .SelectSingleNode(&quot;/flat-profile/Current_IP    [@group=&#039;Info/System_Information&#039;]&quot; ).text
                WScript.Echo .SelectSingleNode(&quot;/flat-profile/MAC_Address   [@group=&#039;Info/Product_Information&#039;]&quot;).text
                WScript.Echo .SelectSingleNode(&quot;/flat-profile/Serial_Number [@group=&#039;Info/Product_Information&#039;]&quot;).text
            Else
                WScript.Echo &quot;Can&#039;t load [http://&quot; &amp; strAddress &amp; &quot;/admin/spacfg.xml].&quot;
            End If
        End With
    End If
Next

WScript.Quit 0
&#039;=============================================================================

&#039;=============================================================================
Function IsEnabled(strAddress)
    Dim objSWbemObject
    
    IsEnabled = False
    
    For Each objSWbemObject In WScript.CreateObject(&quot;WbemScripting.SWbemLocator&quot;).ConnectServer(&quot;.&quot;, &quot;root\cimv2&quot;).ExecQuery(&quot;SELECT * FROM Win32_PingStatus WHERE Address = &#039;&quot; &amp; strAddress &amp; &quot;&#039;&quot;)
        If Not IsNull(objSWbemObject.StatusCode) Then
            If objSWbemObject.StatusCode = 0 Then
                IsEnabled = True
            End If
        End If
    Next
End Function
&#039;=============================================================================
</code></pre></div><p><strong>Space-06</strong>, адрес — это что в примере?</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 18 Jul 2013 13:21:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73881#p73881</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: пакетный парсинг XML]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73872#p73872</link>
			<description><![CDATA[<p><a href="http://rghost.ru/47499831"> Образец Файла</a><br />PowerShell устроит, но если будет возможность в другом исполнении то будет здорово</p>]]></description>
			<author><![CDATA[null@example.com (Space-06)]]></author>
			<pubDate>Thu, 18 Jul 2013 08:53:50 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73872#p73872</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: пакетный парсинг XML]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73866#p73866</link>
			<description><![CDATA[<p><strong>Space-06</strong>, тогда сохраните какой-нибудь из них с помощью IE, упакуйте в архив и выложите на RGhost.</p><p>PowerShell в случае чего Вас устроит?</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 18 Jul 2013 08:12:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73866#p73866</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: пакетный парсинг XML]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73864#p73864</link>
			<description><![CDATA[<p>на пинг откликаются, по http файл доступен без авторизации</p>]]></description>
			<author><![CDATA[null@example.com (Space-06)]]></author>
			<pubDate>Thu, 18 Jul 2013 07:40:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73864#p73864</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: пакетный парсинг XML]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73861#p73861</link>
			<description><![CDATA[<p><strong>Space-06</strong>, они на ICMP-пакеты реагируют, на ping откликаются? Файл доступен по http любому, без каких-либо авторизаций в браузере?</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 18 Jul 2013 07:27:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73861#p73861</guid>
		</item>
		<item>
			<title><![CDATA[VBS: пакетный парсинг XML]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73856#p73856</link>
			<description><![CDATA[<p>Доброго времени суток уважаемые коллеги!!!</p><p>Возник такой вопрос как возможно организовать парсинг XML пакетно, и с выводом результата в текстовый файл?</p><p>Имеется локальная сеть: 192.168.1.0/24 в нее включены IP телефоны, ip адреса которых известны за ранее.<br />Собственно тут то и проблема: каждый конфиг телефона располагается по адресу http://IP/admin/spacfg.xml<br />Нужно прочитать буквально несколько тегов из этого файла:</p><div class="codebox"><pre><code>
&lt;Connection_Type group=&quot;Info/System_Information&quot;&gt;DHCP&lt;/Connection_Type&gt;
&lt;Current_IP group=&quot;Info/System_Information&quot;&gt;192.168.1.120&lt;/Current_IP&gt;
&lt;Host_Name group=&quot;Info/System_Information&quot;&gt;SEP58BFEA1192CC&lt;/Host_Name&gt;
&lt;Domain group=&quot;Info/System_Information&quot;&gt;csoft.org&lt;/Domain&gt;
&lt;Current_Netmask group=&quot;Info/System_Information&quot;&gt;255.255.255.0&lt;/Current_Netmask&gt;
&lt;Current_Gateway group=&quot;Info/System_Information&quot;&gt;192.168.1.1&lt;/Current_Gateway&gt;
&lt;Primary__DNS group=&quot;Info/System_Information&quot;&gt;192.168.1.3&lt;/Primary__DNS&gt;
&lt;Secondary__DNS group=&quot;Info/System_Information&quot;/&gt;
&lt;Product_Name group=&quot;Info/Product_Information&quot;&gt;SPA502G&lt;/Product_Name&gt;
&lt;Serial_Number group=&quot;Info/Product_Information&quot;&gt;CCQ16421D53&lt;/Serial_Number&gt;
&lt;Software_Version group=&quot;Info/Product_Information&quot;&gt;7.5.4&lt;/Software_Version&gt;
&lt;Hardware_Version group=&quot;Info/Product_Information&quot;&gt;1.0.4&lt;/Hardware_Version&gt;
&lt;MAC_Address group=&quot;Info/Product_Information&quot;&gt;58BFEA1192CC&lt;/MAC_Address&gt;
...
</code></pre></div><p>необходимо записать в текстовый файл: ип телефона, адрес, мак адрес и серийный номер</p><p>тут то собственно и загвоздка - как это все выполнить пакетно</p><p>буду рад идеям реализации.</p>]]></description>
			<author><![CDATA[null@example.com (Space-06)]]></author>
			<pubDate>Thu, 18 Jul 2013 04:39:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73856#p73856</guid>
		</item>
	</channel>
</rss>
