Hi everyone,
I'm trying to add XML Node in an XML file with VBS but it don't work (nothing is added).
Can anyone help me ?
I wanted to add a node in the General section (at the end like after CustomImagePath). Here's my code.
Thanks for you help!
I'm trying to add XML Node in an XML file with VBS but it don't work (nothing is added).
Can anyone help me ?
XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!--Phone Account Settings-->
<Accounts>
<Profiles>
<Profile>
<IsActive>True</IsActive>
<AuthByPassword>True</AuthByPassword>
<AuthUser>iWz6iobPfr</AuthUser>
<Codecs>PCMU/8000/1,True;PCMA/8000/1,True;G722/16000/1,True;G729/8000/1,True;opus/48000/2,True;GSM/8000/1,False;speex/8000/1,False;iLBC/8000/1,False</Codecs>
<MaxRegistrationTime>120</MaxRegistrationTime>
<SIPTransport>0</SIPTransport>
<StunAttempts>2</StunAttempts>
<AuthPassword></AuthPassword>
<UseTunnel>True</UseTunnel>
<PBXPort>5060</PBXPort>
<SwitchboardMode>UserMode</SwitchboardMode>
<ShowUnregisteredExtensions>True</ShowUnregisteredExtensions>
<PresenceLayoutOrientation>Vertical</PresenceLayoutOrientation>
<PresenceViewMode>Grouped</PresenceViewMode>
<ActiveCallsFilter>115</ActiveCallsFilter>
<HiddenGroups>2</HiddenGroups>
<HiddenWallboardQueues></HiddenWallboardQueues>
<WallboardCustomMessage1>3CX Wallboard</WallboardCustomMessage1>
<WallboardCustomMessage2></WallboardCustomMessage2>
</Profile>
</Profiles>
<General>
<EchoCancellation>True</EchoCancellation>
<VAD>False</VAD>
<MicGain>4</MicGain>
<IsBusyLampFieldExpanded>False</IsBusyLampFieldExpanded>
<SwitchboardWindowLeft>1433</SwitchboardWindowLeft>
<SwitchboardWindowTop>22</SwitchboardWindowTop>
<SwitchboardWindowWidth>312</SwitchboardWindowWidth>
<SwitchboardWindowHeight>800</SwitchboardWindowHeight>
<IsSwitchboardWindowMaximized>False</IsSwitchboardWindowMaximized>
<DefaultDragAndDropTransferType>Blind</DefaultDragAndDropTransferType>
<ActiveCallsCallerColumnWidth>150</ActiveCallsCallerColumnWidth>
<ActiveCallsCalleeColumnWidth>150</ActiveCallsCalleeColumnWidth>
<ActiveCallsDurationColumnWidth>60</ActiveCallsDurationColumnWidth>
<SwitchboardLayoutTop>428</SwitchboardLayoutTop>
<SwitchboardLayoutBottom>1000</SwitchboardLayoutBottom>
<SwitchboardLayoutLeft>1</SwitchboardLayoutLeft>
<SwitchboardLayoutRight>1</SwitchboardLayoutRight>
<CustomImagePath>C:\ProgramData\3CXPhone for Windows\PhoneApp\HeaderImage.jpeg</CustomImagePath>
</General>
</Accounts>
I wanted to add a node in the General section (at the end like after CustomImagePath). Here's my code.
Code:
Set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.load XMLFILE
'Locate the node
Set nNode2 = xmlDoc.selectsinglenode(XMLNODE)
'Validate if existing
If nNode2 Is Nothing Then
newEle = xmlDoc.createNode("IsCustomImageSet")
newText=xmlDoc.createTextNode("True")
newEle.appendChild(newText)
x = xmlDoc.getElementsByTagName("General")[0]
x.appendChild(newEle)
'set root = xmlDoc.documentElement("General")
'set new_book = xmlDoc.createNode(1, "IsCustomImageSet", "")
'set book_text = xmlDoc.createNode(3, "", "")
'book_text.text = "True"
'new_book.appendChild(book_text)
'root.insertBefore new_book, root.childNodes.Item(0)
End if
'Save the setting
strResult = xmldoc.save(XMLFILE)
Thanks for you help!