473,387 Members | 1,863 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,387 software developers and data experts.

Get all attributes, XPATH

2
Dear All, I am getting stuck with this for a few days :(
and about to decide to give up or find an alternative, but I want to give it a last try :(

My question is how can we write an Xpath expression to get all attributes from an element with ID begins with "ext"

I have tried something like blow, but did not work :(
Expand|Select|Wrap|Line Numbers
  1. //@*[starts-with(@ID,"ext")]
Below is my XML file
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <books>
  3.     <book ID="extension1" available="yes">
  4.         <title>Book Title 1</title>
  5.         <price>100 - 200</price>
  6.     </book>
  7.     <book ID="Book001" available="no">
  8.         <title>Book Title 2</title>
  9.         <price>400 - 500</price>
  10.     </book>
  11.     <book ID="extension2">
  12.         <title>Book Title 3</title>
  13.         <price>abc - 500</price>
  14.     </book>
  15.     <book available="soon">
  16.         <title>Book Title 5</title>
  17.         <price>a100 - c200</price>
  18.     </book>
  19.     <book ID="Book003" available="yes">
  20.         <title>Book Title 6</title>
  21.         <price>c100 - 200</price>
  22.     </book>
  23. </books>
Jul 20 '09 #1
4 14528
arsya
2
There is a mistake in your xpath expression. The correct one is like the following:
Expand|Select|Wrap|Line Numbers
  1. //*[starts-with(@ID,'ext')]
If you need an example of using the xpath starts-with function in Python, see the example #2 in this http://murzal-arsya.blogspot.com/200...hon-using.html
Jul 20 '09 #2
hose
2
then your expression would get all elements :), thanks
Jul 20 '09 #3
arsya
2
Well after getting all the needed nodes then you can select the attributes:

Expand|Select|Wrap|Line Numbers
  1. "//*[starts-with(@ID,'ext')]/@*"
Jul 21 '09 #4
jkmyoung
2,057 Expert 2GB
//@*[starts-with(../@ID,'ext')]
Jul 22 '09 #5

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

Similar topics

1
by: John | last post by:
I'm developing an application for medical use that will be used to capture patient background and visit data. The application will have approximately 50 forms, with an average of about 20 fields...
2
by: Marc A. Criley | last post by:
First off, I'm an experienced software developer but new to XML, so be gentle :-) I've put together a schema that defines optional attributes for some of the elements. Some of these attributes...
1
by: wooks | last post by:
I have some information embedded in included schemas which I want to access at run-time for the purposes of contructing a GUI (they will support field labels and tool tips). The options seem to...
2
by: girish | last post by:
In my XML document, some node attributes data contains both single quot and double quote characters, such as <input msg="Hello "World", What's up"/>. The double quotes are in form of escape...
0
by: mark.van.der.voort | last post by:
Hi, I have defined a simple key/keyref validation for describing a tree. <xs:key name="key_member"> <xs:selector xpath=".//member"/> <xs:field xpath="@id"/> </xs:key> <xs:keyref...
2
by: monsterpot | last post by:
Hello, I have a document like this: <parameters> <param ptype="init">somedata</param> <param ptype="process">moredata</param> <param ptype="kill">alsodata</param> </parameters> <param> has...
1
by: Dave Lech | last post by:
In a C# app I have an XPath query where I am trying to return a single node based on the value of 2 different attributes. The xml looks something like this: <TESTS> <TEST SAMPLE_NUMBER="1"...
2
by: matthewjbarr | last post by:
Sorry for cross-posting, but I posted this in the PHP group and think it probably should have been here - think maybe I should be looking at XPath expressions to solve the problem. E.g. something...
1
by: BillGatesFan | last post by:
Does anyone have any code to get Attributes of an XML Element Using XPATH. I have been trying all day and cannot get this to work. I have been using XPathNavigator, XPathDocument and the...
0
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.