473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

VBA - XML SelectSingleNode - Syntax Problem

4
Refs - See attached images.



My XML file structure is a config file: It works fine

Simply trying to change date between the quotes of "2017-05-10" 'in the StartDate value to 2017-05-11

see attached image for the pop up err on bold line in code

My code I Have so far.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <configuration>
  3.   <configSections>
  4.      ...some xml struc
  5.   </configSections>
  6.  
  7.   <appSetttings>
  8.      <add key="xxx" value="yyy" />
  9.      <add key="xxx" value="www" />
  10.      <add key="StartDate" value="2017-05-10" />
  11.      <add key="EndDate" value="2017-05-25" />
  12.      <add key="zzz" value="nnn" />
  13.   </appSettings> 
  14.  
  15.  etc
  16.  
  17. </configuration>
  18.  
  19. 'Access VBA 2010
  20.  
  21. Dim wXML As Object, xFile As String
  22.  
  23. Set wXML = CreateObject("Microsoft.XMLDOM")
  24.  
  25. xFile = "C:\CTI Group\ArchiveClientTools\v2-0-0\ArchiveClientTools\SRIPArchiveClientForm.exe.config"
  26.  
  27. wXML.Load (xFile)
  28.  
  29. 'errs here.
  30.  
  31. wXML.documentElement.SelectSingleNode("configuration/appSettings/add key/[@Name='StartDate']/value").InnerText = "2017-05-11"
No joy. Am I missing something simple?

Thanks. :o)
Attached Images
File Type: jpg err.jpg (17.6 KB, 634 views)
File Type: jpg refs.jpg (55.9 KB, 633 views)
May 28 '17 #1

✓ answered by CJames

With a little help we got it figured out... Easy in hindsight... not so looking forward before it worked...

*************************************
Expand|Select|Wrap|Line Numbers
  1. Dim wXML As Object, xFile As String
  2.     Set wXML = CreateObject("Microsoft.XMLDOM")
  3.     xFile = "C:\CTI Group\ArchiveClientTools\v2-0-0\ArchiveClientTools\SRIPArchiveClientForm.exe.config"
  4.  
  5.     If wXML.Load(xFile) Then
  6.         wXML.DocumentElement.SelectSingleNode("//add[@key=""StartDate""]").setAttribute "value", "2017-05-11"
  7.         wXML.Save xFile
  8.     Else
  9.         MsgBox wXML.parseError.reason, , wXML.parseError.ErrorCode
  10.     End If
  11.  
  12.     Set wXML = Nothing

2 1917
CJames
4
With a little help we got it figured out... Easy in hindsight... not so looking forward before it worked...

*************************************
Expand|Select|Wrap|Line Numbers
  1. Dim wXML As Object, xFile As String
  2.     Set wXML = CreateObject("Microsoft.XMLDOM")
  3.     xFile = "C:\CTI Group\ArchiveClientTools\v2-0-0\ArchiveClientTools\SRIPArchiveClientForm.exe.config"
  4.  
  5.     If wXML.Load(xFile) Then
  6.         wXML.DocumentElement.SelectSingleNode("//add[@key=""StartDate""]").setAttribute "value", "2017-05-11"
  7.         wXML.Save xFile
  8.     Else
  9.         MsgBox wXML.parseError.reason, , wXML.parseError.ErrorCode
  10.     End If
  11.  
  12.     Set wXML = Nothing
May 29 '17 #2
NeoPa
32,556 Expert Mod 16PB
Glad to see you got it sorted without help. I'm very unfamiliar with all the XML stuff unfortunately.
May 30 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Toonman | last post by:
I'm trying to use a couple of variables in a stored procedure. Things work fine when I hard code the data into the variables and also work fine when I use the variable in the WHERE clause and hard...
2
by: Dominik | last post by:
Hello. I hope I have choosed right group. I have problem preparing SQL syntax. I think it is quite simple but I haven't tried to do this till now. The thing is that I have a string and I must...
2
by: Adam Smith | last post by:
Syntax problem Link works w/ Netscape <a href="passwdhlp.html"> <button type="button" name="Help" style="font: 11pt arial bold; background white;color:red">Help!</button> </a> But not...
17
by: Paul | last post by:
HI! I am trying to dynamically add content into Div tags with the use of JavaScript. it loads the page but adds a few characters. the script is below. <script language="JavaScript">...
2
by: martinharvey via DotNetMonster.com | last post by:
I would be very grateful if someone could help me with a stored procedure syntax problem I want to insert the value "OrderTotal" into databasetable("Newtable") column "OrderTotal" (money (8))....
3
by: Doug | last post by:
Hi, I'm more familiar with MSSQL than Access syntax and have run into a problem with correctly putting ( )'s around the joins in a 3 table query. I want to INNER JOIN lenders and accounts and...
12
by: Brad Baker | last post by:
I am trying to write a simple ASP.net/C# page which allows users to select some values and produce a report based on a SQL query. I have a self posting dropdown form which allows users to select...
2
by: Garry Jones | last post by:
I am having a problem with php syntax. I am sending these values to a form called preview.php but I can not get the syntax working properly. $fornamn1 $eftnamn1 $fornamn2 $eftnamn2
4
by: Call Me Tom | last post by:
I have the following PHP/MySQL code segment $query2="UPDATE reports SET fsacars_rep_url = $url_new WHERE pilot_id = $pid"; echo"$query2"; $result2=mysql_query($query2) or...
9
by: Suresh Jeevanandam | last post by:
Hello everybody! I am using g++ 3.2.3. When I try to do try{} catch{} it works fine if I catch(int a). But if I do catch(SomeException e) it raises syntax errors. Any guess whats wrong? ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.