×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Add XML Node with VBS

Add XML Node with VBS

Add XML Node with VBS

(OP)
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 ?

CODE --> 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 --> VBS

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! smile

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close