473,562 Members | 3,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get all attributes, XPATH

2 New Member
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 14563
2 New Member
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
2 New Member
then your expression would get all elements :), thanks
Jul 20 '09 #3
2 New Member
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
2,057 Recognized Expert Top Contributor
Jul 22 '09 #5

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

Similar topics

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 each-- so a total of 1000+ fields. Almost always, the fields are unique to a particular form--and it will be pretty unlikely that new forms and...
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 have default values defined for them in the schema. XML files that employ that schema may of course then have entries that omit the...
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 be to store them as documentation/appinfo elements within the included schema or as unhandled attributes. Because the schemas are included it...
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 sequence in the XML document. am not able to locate such elements using an XPath expression. I trie the following: //*
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 name="ref_parent_member" refer="key_member"> <xs:selector xpath=".//member"/>
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 the following definition in my XSD:
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" TEST_NUMBER="1"/> <TEST SAMPLE_NUMBER="1" TEST_NUMBER="2"/> <TEST SAMPLE_NUMBER="2" TEST_NUMBER="1"/> <TEST SAMPLE_NUMBER="2" TEST_NUMBER="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 like this: $item->xpath("//movie:image@src") *** Hi there,
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 XPathNodeIterator trying to get the url attribute of the following XML: <?xml version='1.0' encoding='utf-8' ?> <Message> <Internet> <site...
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 some values while leaving the other values alone. I am designing this database/table/column so maybe I could use attributes or elements/nodes, the...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.