I have to correct my statement. [] also can be an indexer. But it should be 
used very carefully. It is much cleaner to see [] a predicate and 
[position()=2] for example is better choice for such indexed location. However, 
MSXML 3.0 does not support position() function as will be shown below.

As MSXML 3.0 uses zero-based index, MSXML 4.0 and XML standard (so-called in 
MSDN) uses 1-based index. .NET Framework library also conforms XML standard. As 
I see the wix source dutil/xmlutil.cpp (if this is the correct one), it uses 
MSXML 3.0 deliberately. Use of 4.0 may lead other problems, though.

So, I would recommend you use a predicate like [EMAIL PROTECTED]'something2'] 
and avoid numerical index for your cases.

Wix documentation may have to clarify that XmlUtil uses MSXML 3.0 the users 
should use MSXML 3.0 specification.
 
Below show different behaviors in different versions of MSXML:

-----------------------
MSXML2.DOMDocument.3.0
-----------------------

XPath=/Configuration/companyname/vals/add/@value
 >>> value="value1"

XPath=/Configuration/companyname/vals/add[0]/@value
 >>> value="value1"

XPath=/Configuration/companyname/vals/add[1]/@value
 >>> value="valueIwanttoupdate"

XPath=/Configuration/companyname/vals/add[2]/@value
 >>> (null)

XPath=/Configuration/companyname/vals/add[position()=2]/@value
exception: Unknown method.

/Configuration/companyname/vals/add[-->position()<--=2]/@value

XPath=/Configuration/companyname/vals/[EMAIL PROTECTED]'something2']/@value
 >>> value="valueIwanttoupdate"



-----------------------
MSXML2.DOMDocument.4.0
-----------------------

XPath=/Configuration/companyname/vals/add/@value
 >>> value="value1"

XPath=/Configuration/companyname/vals/add[0]/@value
 >>> (null)

XPath=/Configuration/companyname/vals/add[1]/@value
 >>> value="value1"

XPath=/Configuration/companyname/vals/add[2]/@value
 >>> value="valueIwanttoupdate"

XPath=/Configuration/companyname/vals/add[position()=2]/@value
 >>> value="valueIwanttoupdate"

XPath=/Configuration/companyname/vals/[EMAIL PROTECTED]'something2']/@value
 >>> value="valueIwanttoupdate"

-----------------------
XML in .NET Framework
-----------------------

XPath=/Configuration/companyname/vals/add/@value
 >>> value1
XPath=/Configuration/companyname/vals/add[0]/@value
 >>> (null)
XPath=/Configuration/companyname/vals/add[1]/@value
 >>> value1
XPath=/Configuration/companyname/vals/add[2]/@value
 >>> valueIwanttoupdate
XPath=/Configuration/companyname/vals/add[position()=2]/@value
 >>> valueIwanttoupdate
XPath=/Configuration/companyname/vals/[EMAIL PROTECTED]'something2']/@value
 >>> valueIwanttoupdate



Chesong Lee

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chesong Lee
Sent: Thursday, August 31, 2006 5:22 PM
To: Scott Sam; wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] Using XmlFile to update an existing attribute

Isn't it possible to use the xpath like this?
[] in XPath is not a numerical index but node test predicate.
 
/Configuration/companyname/vals/[EMAIL PROTECTED]'something2']/@value

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Scott Sam
Sent: Thursday, August 31, 2006 4:51 PM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] Using XmlFile to update an existing attribute

I'm trying to set the value of an attribute to the machine name.  this
is a snippet of the xml file.

<Configuration>
.
.
.
<companyname>
<vals>
<add name="something" value="value1" />
<add name="something2" value="valueIwanttoupdate" />
</vals>
</companyname>
</Configuration>

When I use the //Configuration/Companyname[1]/vals[1]/add[2] for the
ElementPath it updates value1 no matter what add I reference.

Any ideas why this happens?  How can I update the value attribute of the
2nd add element in the group.  I don't want to create a new element,
because all the elements already exist along with all of their
attributes.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to