473,503 Members | 3,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XPath query for <?define something="something" ?>

Hi,

How I can find <?something ?stuff?

XML:
<Wix>
<?define UpgradeCode="{foobar-quux-xyzzy}"?>
<?define Manufacturer="Company"?>
<!-- update this ALWAYS -->
<?define PackageCode="REPLACE"?>
</Wix>

How to match that REPLACE with XPath? Or even better: find only define
and PackageCode
Doesn't work:
/Wix[processing-instruction('define[@PackageCode='REPLACE']')]
/Wix[processing-instruction('define')/[@PackageCode='REPLACE']/
@PackageCode]
/Wix[processing-instruction('define')/[@PackageCode='REPLACE']]/
@PackageCode
/Wix[processing-instruction('define[@PackageCode='REPLACE']')/]/
@PackageCode

Works:
/Wix[processing-instruction('define')[3]]

But PackageCode isn't necessary always third.
Jun 27 '08 #1
2 4015
* Pekka Järvinen wrote in comp.text.xml:
>How I can find <?something ?stuff?

XML:
<Wix>
<?define UpgradeCode="{foobar-quux-xyzzy}"?>
<?define Manufacturer="Company"?>
<!-- update this ALWAYS -->
<?define PackageCode="REPLACE"?>
</Wix>

How to match that REPLACE with XPath? Or even better: find only define
and PackageCode
Doesn't work:
/Wix[processing-instruction('define[@PackageCode='REPLACE']')]
/Wix[processing-instruction('define')/[@PackageCode='REPLACE']/
@PackageCode]
/Wix[processing-instruction('define')/[@PackageCode='REPLACE']]/
@PackageCode
/Wix[processing-instruction('define[@PackageCode='REPLACE']')/]/
@PackageCode
These do not work because the processing instruction data is simply a
string, there are no attributes, they just look like them. You have to
access the data by querying the PI's string value, so e.g.

//processing-instruction('define')[ . = 'PackageCode="REPLACE"']

This would find all <?define PackageCode="REPLACE"?nodes. To parse
the string value use functions like substring-before() and substring().
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 27 '08 #2
In article <8f**********************************@k13g2000hse. googlegroups.com>,
Pekka Järvinen <pe************@gmail.comwrote:
><?define PackageCode="REPLACE"?>
The stuff in the <?define ... ?is not an attribute. It's just some
text that looks like an attribute. You can match it as text:

processing-instruction("define")[. = 'PackageCode="REPLACE"']
or
processing-instruction("define")[contains(., "REPLACE")]

-- Richard
--
:wq
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2785
by: Eric A. Forgy | last post by:
Hello, I am just learning Java and am trying to write a method that does something like //=========================================== public Static List find(double array,double val,String...
7
9005
by: Ensoul Chee | last post by:
I used #include <iostream.h> int m; cout << "Hexadecimal == 0x" << hex << m << endl; to print value of m in hexadecimal mode. But I got the compile error like this couttest.cpp:20 `hex'...
2
5148
by: Mark Bordner | last post by:
Hi All, Given the following XML, I've been trying to figure out what XPATH expression will give me the "position" of a <lineitem> within the <shipto> that is its grandparent. To give you an...
16
1916
by: rik | last post by:
I was flicking through a PHP book (one of the teach in 24 hour ones) and I came across something I had never seen before in PHP. It was a method of printing out without using the print method, it...
4
1733
by: wangzhihuii | last post by:
Hi all, I'm really confused, can cout<<""; contribute anything to the routine ?!! my programm won't work properly without this trivial sentence. Sincerely vivian
2
1569
by: Rob Meade | last post by:
Hi all, I am getting the above error when I try to flick from HTML to Design view in Visual Studio - I get the jist of the error message, and I know the line of code which it refers to which is...
17
2388
by: Chen Shusheng | last post by:
Hi all, In fact, I want to let my memory run out. And see what will happen. My system is windowsXp. Memory is 256M.I think my cdes will apply more memory than I have. Codes are below: ...
3
2149
by: key9 | last post by:
Hi all I am confuse of how to override operate "<<" Sample , I've got 2 class class Terminal { public:
5
2281
by: tuxedo | last post by:
The way the <body onload="something()"works ensures that the complete html document is loaded before something() is executed. Can the same be achieved when placing the onload call in document...
0
7188
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
7258
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
7313
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
7441
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
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4987
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...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.