How do I remove all Handheld nodes/infomration from xml file? I would like
to know how to remove all HandHeld nodes and/or removing HandHelds
completly.



XML FILE FORMAT

<Store>
<HandHelds>
<HandHeld Number="51" MacAddress="00A0F8623CA0"
IPAddress="10.117.80.47" Gateway="10.117.80.1" DNS="172.17.4.12"
SubnetMask="255.255.255.0"/>
<HandHeld Number="52" MacAddress="00A0F84A1259"
IPAddress="10.117.80.48" Gateway="10.117.80.1" DNS="172.17.4.12"
SubnetMask="255.255.255.0"/>
<HandHeld Number="53" MacAddress="00A0F843E3FF"
IPAddress="10.117.80.49" Gateway="10.117.80.1" DNS="172.17.4.12"
SubnetMask="255.255.255.0"/>
<HandHeld Number="55" MacAddress="00A0F86240C9"
IPAddress="10.117.80.51" Gateway="10.117.80.1" DNS="172.17.4.12"
SubnetMask="255.255.255.0"/>
<HandHeld Number="54" MacAddress="00A0F84A089F"
IPAddress="10.117.80.50" Gateway="10.117.80.1" DNS="172.17.4.12"
SubnetMask="255.255.255.0"/>
<HandHeld Number="56" MacAddress="00A0F84B51FF"
IPAddress="10.117.80.52" Gateway="10.117.80.1" DNS="172.17.4.12"
SubnetMask="255.255.255.0"/>
</HandHelds>
</Store>




Const StoreXML_DROPOFF_DIR = "C:\Program Files\xml\"
Const StoreXML_FileName = "HHInfo.xml"

Dim xml
Dim HHnodeList
Dim HHnode
Dim HHNum
Dim j


Set xml = CreateObject("MSXML.DOMDocument") 'create intance of XML object.
xml.async = False
xml.load StoreXML_DROPOFF_DIR & StoreXML_FileName



Set HHnodeList = xml.selectNodes("//Store/HandHelds/HandHeld")
Set HHnode = xml.documentElement.selectSingleNode("//Store/Handhelds")

For j = 0 To HHnodeList.length -1
HHNum=HHnodeList(j).Attributes.getNamedItem("Number").value
WScript.Echo(HHNum)
HHnode.removeChild HHnode.childNodes.Item(HHNum)
Next

Re: remove nodes from xml by mr_unreliable

mr_unreliable
Wed Apr 12 12:22:47 CDT 2006

hi Big D,

Everything you need is provided by: "MSXML2.DOMDocument", (an actX
object).

It provides methods for reading in your xml file, deleting nodes,
and writing back out the updated file, (and much more).

You can find out all the members (methods and properties) by
looking them up on msdn.microsoft.com. You can also find numerous
examples of code by searching the archives of this ng.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)




Big D wrote:
> How do I remove all Handheld nodes/infomration from xml file? I would like
> to know how to remove all HandHeld nodes and/or removing HandHelds
> completly.
>
>
>
> XML FILE FORMAT
>
> <Store>
> <HandHelds>
> <HandHeld Number="51" MacAddress="00A0F8623CA0"
> IPAddress="10.117.80.47" Gateway="10.117.80.1" DNS="172.17.4.12"
> SubnetMask="255.255.255.0"/>
> <HandHeld Number="52" MacAddress="00A0F84A1259"
> IPAddress="10.117.80.48" Gateway="10.117.80.1" DNS="172.17.4.12"
> SubnetMask="255.255.255.0"/>
> <HandHeld Number="53" MacAddress="00A0F843E3FF"
> IPAddress="10.117.80.49" Gateway="10.117.80.1" DNS="172.17.4.12"
> SubnetMask="255.255.255.0"/>
> <HandHeld Number="55" MacAddress="00A0F86240C9"
> IPAddress="10.117.80.51" Gateway="10.117.80.1" DNS="172.17.4.12"
> SubnetMask="255.255.255.0"/>
> <HandHeld Number="54" MacAddress="00A0F84A089F"
> IPAddress="10.117.80.50" Gateway="10.117.80.1" DNS="172.17.4.12"
> SubnetMask="255.255.255.0"/>
> <HandHeld Number="56" MacAddress="00A0F84B51FF"
> IPAddress="10.117.80.52" Gateway="10.117.80.1" DNS="172.17.4.12"
> SubnetMask="255.255.255.0"/>
> </HandHelds>
> </Store>
>
>
>
>
> Const StoreXML_DROPOFF_DIR = "C:\Program Files\xml\"
> Const StoreXML_FileName = "HHInfo.xml"
>
> Dim xml
> Dim HHnodeList
> Dim HHnode
> Dim HHNum
> Dim j
>
>
> Set xml = CreateObject("MSXML.DOMDocument") 'create intance of XML object.
> xml.async = False
> xml.load StoreXML_DROPOFF_DIR & StoreXML_FileName
>
>
>
> Set HHnodeList = xml.selectNodes("//Store/HandHelds/HandHeld")
> Set HHnode = xml.documentElement.selectSingleNode("//Store/Handhelds")
>
> For j = 0 To HHnodeList.length -1
> HHNum=HHnodeList(j).Attributes.getNamedItem("Number").value
> WScript.Echo(HHNum)
> HHnode.removeChild HHnode.childNodes.Item(HHNum)
> Next
>
>
>
>
>
>
>
>
>