From: Don on 18 Jun 2010 14:08 Right now I just want to be able to read (Echo out) the Value of "VALUE" in an XML element node, and eventually modify it. This will be run with the Windows Scripting Host from a Windows command line. Here is the line of XML I want to read from: <IP_ADDRESS VALUE = "0.0.0.0"/> Here is the code I have right now. All I can get out of it now is tell me the name of the Node and the fact that Type of node is an element. I want it to show me "0.0.0.0" The code I have now. <job id="SetIlofile"> <script language="VBScript"> '----- Open file ------------------------------------- Set objXmlDoc = CreateObject("Microsoft.XMLDOM") objXmlDoc.async = False objXmlDoc.load("ilo.xml") If Not objXmlDoc.load("ilo.xml") Then WScript.Echo "Document failed to load." WScript.Quit End If '------------------------------------------------- Set colNodes = objXmlDoc.selectNodes("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS") '---------------------------------------------------------------------------------- For Each objNode in colNodes WScript.Echo objNode.nodeName, objNode.nodeTypeString Next </script> </job> And my test XML file: <!-- HPONCFG VERSION = "3.0.0.0" --> <!-- Generated 06/17/10 15:03:06 --> <RIBCL VERSION="2.1"> <LOGIN USER_LOGIN="Administrator" PASSWORD="password"> <DIR_INFO MODE="write"> <MOD_DIR_CONFIG> <DIR_AUTHENTICATION_ENABLED VALUE = "N"/> <DIR_LOCAL_USER_ACCT VALUE = "Y"/> </MOD_DIR_CONFIG> </DIR_INFO> <RIB_INFO MODE="write"> <MOD_NETWORK_SETTINGS> <SPEED_AUTOSELECT VALUE = "Y"/> <NIC_SPEED VALUE = "10"/> <IP_ADDRESS VALUE = "0.0.0.0"/> </MOD_NETWORK_SETTINGS> </RIB_INFO> <USER_INFO MODE="write"> </USER_INFO> </LOGIN> </RIBCL>
From: James Whitlow on 18 Jun 2010 16:22 "Don" <Don(a)discussions.microsoft.com> wrote in message news:E90B7DE2-F09D-4219-A774-0BE20DCF5A96(a)microsoft.com... > Right now I just want to be able to read (Echo out) the Value of "VALUE" > in > an XML element node, and eventually modify it. > > This will be run with the Windows Scripting Host from a Windows command > line. > > Here is the line of XML I want to read from: > > <IP_ADDRESS VALUE = "0.0.0.0"/> > > Here is the code I have right now. All I can get out of it now is tell me > the name of the Node and the fact that Type of node is an element. I want > it > to show me "0.0.0.0" > > The code I have now. > > <job id="SetIlofile"> > <script language="VBScript"> > '----- Open file ------------------------------------- > Set objXmlDoc = CreateObject("Microsoft.XMLDOM") > objXmlDoc.async = False > objXmlDoc.load("ilo.xml") > If Not objXmlDoc.load("ilo.xml") Then > WScript.Echo "Document failed to load." > WScript.Quit > End If > '------------------------------------------------- > Set colNodes = > objXmlDoc.selectNodes("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS") > '---------------------------------------------------------------------------------- > For Each objNode in colNodes > WScript.Echo objNode.nodeName, objNode.nodeTypeString > Next > </script> > </job> > > And my test XML file: > > <!-- HPONCFG VERSION = "3.0.0.0" --> > <!-- Generated 06/17/10 15:03:06 --> > <RIBCL VERSION="2.1"> > <LOGIN USER_LOGIN="Administrator" PASSWORD="password"> > <DIR_INFO MODE="write"> > <MOD_DIR_CONFIG> > <DIR_AUTHENTICATION_ENABLED VALUE = "N"/> > <DIR_LOCAL_USER_ACCT VALUE = "Y"/> > </MOD_DIR_CONFIG> > </DIR_INFO> > <RIB_INFO MODE="write"> > <MOD_NETWORK_SETTINGS> > <SPEED_AUTOSELECT VALUE = "Y"/> > <NIC_SPEED VALUE = "10"/> > <IP_ADDRESS VALUE = "0.0.0.0"/> > </MOD_NETWORK_SETTINGS> > </RIB_INFO> > <USER_INFO MODE="write"> > </USER_INFO> > </LOGIN> > </RIBCL> See if these modifications help. <job id="SetIlofile"> <script language="VBScript"> '----- Open file ------------------------------------- Set objXmlDoc = CreateObject("MSXML.DOMDocument") objXmlDoc.async = False objXmlDoc.load("ilo.xml") If Not objXmlDoc.load("ilo.xml") Then WScript.Echo "Document failed to load." WScript.Quit End If Set oIP = objXmlDoc.SelectSingleNode _ ("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS/@VALUE") MsgBox oIP.Value oIP.Value = "1.2.3.4" 'Write a new value objXMLDoc.Save("ilo.xml") 'Save the changes back to the XML file </script> </job>
From: Don on 18 Jun 2010 18:46 Thanks! That is what I want it to do. Maybe someday I will learn how to program myself. "James Whitlow" wrote: > > "Don" <Don(a)discussions.microsoft.com> wrote in message > news:E90B7DE2-F09D-4219-A774-0BE20DCF5A96(a)microsoft.com... > > Right now I just want to be able to read (Echo out) the Value of "VALUE" > > in > > an XML element node, and eventually modify it. > > > > This will be run with the Windows Scripting Host from a Windows command > > line. > > > > Here is the line of XML I want to read from: > > > > <IP_ADDRESS VALUE = "0.0.0.0"/> > > > > Here is the code I have right now. All I can get out of it now is tell me > > the name of the Node and the fact that Type of node is an element. I want > > it > > to show me "0.0.0.0" > > > > The code I have now. > > > > <job id="SetIlofile"> > > <script language="VBScript"> > > '----- Open file ------------------------------------- > > Set objXmlDoc = CreateObject("Microsoft.XMLDOM") > > objXmlDoc.async = False > > objXmlDoc.load("ilo.xml") > > If Not objXmlDoc.load("ilo.xml") Then > > WScript.Echo "Document failed to load." > > WScript.Quit > > End If > > '------------------------------------------------- > > Set colNodes = > > objXmlDoc.selectNodes("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS") > > '---------------------------------------------------------------------------------- > > For Each objNode in colNodes > > WScript.Echo objNode.nodeName, objNode.nodeTypeString > > Next > > </script> > > </job> > > > > And my test XML file: > > > > <!-- HPONCFG VERSION = "3.0.0.0" --> > > <!-- Generated 06/17/10 15:03:06 --> > > <RIBCL VERSION="2.1"> > > <LOGIN USER_LOGIN="Administrator" PASSWORD="password"> > > <DIR_INFO MODE="write"> > > <MOD_DIR_CONFIG> > > <DIR_AUTHENTICATION_ENABLED VALUE = "N"/> > > <DIR_LOCAL_USER_ACCT VALUE = "Y"/> > > </MOD_DIR_CONFIG> > > </DIR_INFO> > > <RIB_INFO MODE="write"> > > <MOD_NETWORK_SETTINGS> > > <SPEED_AUTOSELECT VALUE = "Y"/> > > <NIC_SPEED VALUE = "10"/> > > <IP_ADDRESS VALUE = "0.0.0.0"/> > > </MOD_NETWORK_SETTINGS> > > </RIB_INFO> > > <USER_INFO MODE="write"> > > </USER_INFO> > > </LOGIN> > > </RIBCL> > > See if these modifications help. > > <job id="SetIlofile"> > <script language="VBScript"> > '----- Open file ------------------------------------- > Set objXmlDoc = CreateObject("MSXML.DOMDocument") > objXmlDoc.async = False > objXmlDoc.load("ilo.xml") > If Not objXmlDoc.load("ilo.xml") Then > WScript.Echo "Document failed to load." > WScript.Quit > End If > Set oIP = objXmlDoc.SelectSingleNode _ > ("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS/@VALUE") > MsgBox oIP.Value > oIP.Value = "1.2.3.4" 'Write a new value > objXMLDoc.Save("ilo.xml") 'Save the changes back to the XML file > </script> > </job> > > > . >
From: Виктор Базаров on 21 Jun 2010 08:08 I can't load XML by objXmlDoc.load method error: cannot load xml, check parameters what's wrong? "James Whitlow" <jwhitlow.60372693(a)bloglines.com> �������(�) � �������� ���������:OuM97PyDLHA.5736(a)TK2MSFTNGP02.phx.gbl... > > "Don" <Don(a)discussions.microsoft.com> wrote in message > news:E90B7DE2-F09D-4219-A774-0BE20DCF5A96(a)microsoft.com... >> Right now I just want to be able to read (Echo out) the Value of "VALUE" >> in >> an XML element node, and eventually modify it. >> >> This will be run with the Windows Scripting Host from a Windows command >> line. >> >> Here is the line of XML I want to read from: >> >> <IP_ADDRESS VALUE = "0.0.0.0"/> >> >> Here is the code I have right now. All I can get out of it now is tell me >> the name of the Node and the fact that Type of node is an element. I want >> it >> to show me "0.0.0.0" >> >> The code I have now. >> >> <job id="SetIlofile"> >> <script language="VBScript"> >> '----- Open file ------------------------------------- >> Set objXmlDoc = CreateObject("Microsoft.XMLDOM") >> objXmlDoc.async = False >> objXmlDoc.load("ilo.xml") >> If Not objXmlDoc.load("ilo.xml") Then >> WScript.Echo "Document failed to load." >> WScript.Quit >> End If >> '------------------------------------------------- >> Set colNodes = >> objXmlDoc.selectNodes("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS") >> '---------------------------------------------------------------------------------- >> For Each objNode in colNodes >> WScript.Echo objNode.nodeName, objNode.nodeTypeString >> Next >> </script> >> </job> >> >> And my test XML file: >> >> <!-- HPONCFG VERSION = "3.0.0.0" --> >> <!-- Generated 06/17/10 15:03:06 --> >> <RIBCL VERSION="2.1"> >> <LOGIN USER_LOGIN="Administrator" PASSWORD="password"> >> <DIR_INFO MODE="write"> >> <MOD_DIR_CONFIG> >> <DIR_AUTHENTICATION_ENABLED VALUE = "N"/> >> <DIR_LOCAL_USER_ACCT VALUE = "Y"/> >> </MOD_DIR_CONFIG> >> </DIR_INFO> >> <RIB_INFO MODE="write"> >> <MOD_NETWORK_SETTINGS> >> <SPEED_AUTOSELECT VALUE = "Y"/> >> <NIC_SPEED VALUE = "10"/> >> <IP_ADDRESS VALUE = "0.0.0.0"/> >> </MOD_NETWORK_SETTINGS> >> </RIB_INFO> >> <USER_INFO MODE="write"> >> </USER_INFO> >> </LOGIN> >> </RIBCL> > > See if these modifications help. > > <job id="SetIlofile"> > <script language="VBScript"> > '----- Open file ------------------------------------- > Set objXmlDoc = CreateObject("MSXML.DOMDocument") > objXmlDoc.async = False > objXmlDoc.load("ilo.xml") > If Not objXmlDoc.load("ilo.xml") Then > WScript.Echo "Document failed to load." > WScript.Quit > End If > Set oIP = objXmlDoc.SelectSingleNode _ > ("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS/@VALUE") > MsgBox oIP.Value > oIP.Value = "1.2.3.4" 'Write a new value > objXMLDoc.Save("ilo.xml") 'Save the changes back to the XML file > </script> > </job> >
From: Виктор Базаров on 21 Jun 2010 09:08 it's enough to delete "( )" in load method. "������ �������" <bazarovvs(a)gmail.com> �������(�) � �������� ���������:uAcFDqTELHA.4504(a)TK2MSFTNGP02.phx.gbl... > I can't load XML by objXmlDoc.load method > error: cannot load xml, check parameters > what's wrong? > > "James Whitlow" <jwhitlow.60372693(a)bloglines.com> �������(�) � �������� > ���������:OuM97PyDLHA.5736(a)TK2MSFTNGP02.phx.gbl... >> >> "Don" <Don(a)discussions.microsoft.com> wrote in message >> news:E90B7DE2-F09D-4219-A774-0BE20DCF5A96(a)microsoft.com... >>> Right now I just want to be able to read (Echo out) the Value of "VALUE" >>> in >>> an XML element node, and eventually modify it. >>> >>> This will be run with the Windows Scripting Host from a Windows command >>> line. >>> >>> Here is the line of XML I want to read from: >>> >>> <IP_ADDRESS VALUE = "0.0.0.0"/> >>> >>> Here is the code I have right now. All I can get out of it now is tell >>> me >>> the name of the Node and the fact that Type of node is an element. I >>> want it >>> to show me "0.0.0.0" >>> >>> The code I have now. >>> >>> <job id="SetIlofile"> >>> <script language="VBScript"> >>> '----- Open file ------------------------------------- >>> Set objXmlDoc = CreateObject("Microsoft.XMLDOM") >>> objXmlDoc.async = False >>> objXmlDoc.load("ilo.xml") >>> If Not objXmlDoc.load("ilo.xml") Then >>> WScript.Echo "Document failed to load." >>> WScript.Quit >>> End If >>> '------------------------------------------------- >>> Set colNodes = >>> objXmlDoc.selectNodes("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS") >>> '---------------------------------------------------------------------------------- >>> For Each objNode in colNodes >>> WScript.Echo objNode.nodeName, objNode.nodeTypeString >>> Next >>> </script> >>> </job> >>> >>> And my test XML file: >>> >>> <!-- HPONCFG VERSION = "3.0.0.0" --> >>> <!-- Generated 06/17/10 15:03:06 --> >>> <RIBCL VERSION="2.1"> >>> <LOGIN USER_LOGIN="Administrator" PASSWORD="password"> >>> <DIR_INFO MODE="write"> >>> <MOD_DIR_CONFIG> >>> <DIR_AUTHENTICATION_ENABLED VALUE = "N"/> >>> <DIR_LOCAL_USER_ACCT VALUE = "Y"/> >>> </MOD_DIR_CONFIG> >>> </DIR_INFO> >>> <RIB_INFO MODE="write"> >>> <MOD_NETWORK_SETTINGS> >>> <SPEED_AUTOSELECT VALUE = "Y"/> >>> <NIC_SPEED VALUE = "10"/> >>> <IP_ADDRESS VALUE = "0.0.0.0"/> >>> </MOD_NETWORK_SETTINGS> >>> </RIB_INFO> >>> <USER_INFO MODE="write"> >>> </USER_INFO> >>> </LOGIN> >>> </RIBCL> >> >> See if these modifications help. >> >> <job id="SetIlofile"> >> <script language="VBScript"> >> '----- Open file ------------------------------------- >> Set objXmlDoc = CreateObject("MSXML.DOMDocument") >> objXmlDoc.async = False >> objXmlDoc.load("ilo.xml") >> If Not objXmlDoc.load("ilo.xml") Then >> WScript.Echo "Document failed to load." >> WScript.Quit >> End If >> Set oIP = objXmlDoc.SelectSingleNode _ >> ("/RIBCL/LOGIN/RIB_INFO/MOD_NETWORK_SETTINGS/IP_ADDRESS/@VALUE") >> MsgBox oIP.Value >> oIP.Value = "1.2.3.4" 'Write a new value >> objXMLDoc.Save("ilo.xml") 'Save the changes back to the XML file >> </script> >> </job> >>
|
Pages: 1 Prev: Ubound Suscript Error in Multidimensional array Next: Can this VBA be translated to VBScript? |