XPath Query Help

I'm trying to write a query to pull all the specific fields from a xml
file.  The XML is structured in such a way that nested child elements
in a section will determine if a field exists in a form.  In order to
show all the fields in an xml file I need to get all XML elements
between two elements.

Here is an example:

    <elem><tag="start" /></elem>
    <elem><val>Keep this one</val></elem>
    <elem><tag="stop" /></elem>
    <elem><val>Discard Me</val></elem>
    <elem><tag="start" /></elem>
    <elem><val>Keep this one</val></elem>
    <elem><tag="stop" /></elem>

I want to get the <val> tags between the start and stop tags, and
discard the <val> tags outside of the start/stop tags.
Anyone know how to write an XPath query to give me this?  I've been
frustrated over it for a while now using Visual XPath to figure it


verifex (3)
11/8/2007 12:53:59 AM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 10

Brendan CM wrote:

> Here is an example:
> <root>
>   <container>
>     <elem><tag="start" /></elem>
What is that? That is not well-formed XML.

>     <elem><val>Keep this one</val></elem>
>     <elem><tag="stop" /></elem>
Same here.


	Martin Honnen --- MVP XML
mahotrash (1778)
11/8/2007 1:31:09 PM
Ok, figured it out, given the following XML:
    <elem><tag v="start"></tag></elem>
    <elem><val>Keep this one</val></elem>
    <elem><val>Keep this one too</val></elem>
    <elem><tag v="stop"></tag></elem>
    <elem><val>Discard Me</val></elem>
    <elem><tag v="start"></tag></elem>
    <elem><val>Keep this one</val></elem>
    <elem><tag v="stop"></tag></elem>

This XPath will return only elems within the start stop tags:

verifex (3)
11/8/2007 7:43:59 PM
On Nov 8, 5:31 am, Martin Honnen <mahotr...@yahoo.de> wrote:
> Brendan CM wrote:
> > Here is an example:
> > <root>
> >   <container>
> >     <elem><tag="start" /></elem>
>               ^^^^^^^^^^^
> What is that? That is not well-formed XML.
Okay, it was just an example, here is some well formed XML:

    <elem><tag v="start"></tag></elem>
    <elem><val>Keep this one</val></elem>
    <elem><tag v="stop"></tag></elem>
    <elem><val>Discard Me</val></elem>
    <elem><tag v="start"></tag></elem>
    <elem><val>Keep this one</val></elem>
    <elem><tag v="stop"></tag></elem>

Same question applies though, surely someone here knows that last
little bit of XPath that I'm missing.
This is what I've got so far: //elem[tag[@v="start"]]/following-
And it doesn't work.  :(

verifex (3)
11/8/2007 7:45:29 PM

Similar Artilces:

Help! Help! Help please: CRM Deployment Manager, Workflow manager!!
This is a multi-part message in MIME format. ------=_NextPart_000_001C_01C50AAE.4D0B9880 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have installed CRM server 1.0 on Windows Ad 2000 Server and all the = required service and applications have been started/installed. On CRM Deployment: The licence manager has been confugured and licenced = users. The first problem was that ' I did not have right to perform the = action'. Now, after four days, I access the system and it says that " = it is not responding... contact syste...

Using XPath I am querying parts of XML document, " get quoted by \ - is it possible to specify not to quote " with \? <RootElement> <Element Attribute="SomeValue" /> </RootElement> XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); XmlNode xmlNode = xmlDoc.SelectSingleNode("//RootElement/Element") Print xmlNode.OuterXml <Element Attribute=\"SomeValue\"/> where I was expecting to get <Element Attribute="SomeValue"/> TIA Dennis wrote: > Using XPath I am querying parts of XML document,...

Need Help Fast! How to Calculate a sales percentage
I am trying to give the sales percentage between two cells and am not sure how to do it... Any help would be greatly appreciated. I am under a deadline!! To get the percentage that A1 is of A2, simply divide A1 by A2 and format the cell that contains the formula as percentage. The formula is =A1/A2 HTH Otto "JacoPeanut" <JacoPeanut@discussions.microsoft.com> wrote in message news:0995C18B-6AB5-4C01-A5D3-C8ECC389CB55@microsoft.com... > I am trying to give the sales percentage between two cells and am not sure > how to do it... Any help would be greatly...

This picture outs tears in your eye...:'(:'( http://cdn.news.aol.com/aolnews_photos/01/01/20060802125009990013 http://cdn.news.aol.com/aolnews_photos/0b/05/20060802125509990029 http://cdn.news.aol.com/aolnews_photos/08/02/20060802125309990002 http://cdn.news.aol.com/aolnews_photos/02/04/20060802125409990021 Officials in the eastern city of Jining said Thursday they would kill all dogs within three miles of areas where rabies had been found, the official Xinhua News Agency said. The measure came in response to the deaths of 16 people from rabies in Jining in the last eight month...

Interactive Web database with query capabilty
I see lots of questions about using Access as an interactive web database but many of the answers seem to dance all around the question. Let me be as precise with the question as possbile... Here is a online database that is exactly like what I want to do with Access http://www.osalt.org/events/osalt http://www.osalt.org/events/submit This interface was created with something called Ruby on Rails. (1) Can this same thing be done with Access and asp? (2) Can you provide an example of an access database that offers the same query capability and submission capability? I have done a si...

exceL NOOB needs help w/sales tracking
I manage a nightclub and want to create a sales tracking chart pe server. This is easy if all servers occupied the same cells on ever worksheet. However, corporate insists that the daily sales report b designed around stations. Therefore, my servers rotate from station t station on a daily basis. I know i could always make a seperat worksheet designed around the servers and input the server totals second time onto that worksheet but i was hoping of finding someway o linking a second worksheet that totals up the sales per server as enter them into the daily sales report (the one designed ...

hi, I have a real problem - that is getting to me, ok here goes sheet 1 lists transactions by departments on sheet 2 I would like to be able to add up the transactions for each dept. The problem is that the dept is column D but the amount is Column I any ideas ? David A Pivot Table is what you want. You can use the data on sheet1 and put the results on sheet2 If you are not familiar with Pivot Tables, see: http://peltiertech.com/Excel/Pivots/pivotstart.htm -- Gary's Student "David Cleland" wrote: > hi, > > I have a real problem - that is getting to me,...

Getting a specific parent of any node via xpath navigation
I am storing my site structure as such: <menuItems> <menuItem> <pageID>1</pageID> </menuItem> <menuItem> <pageID>2</pageID> <menuItem> <pageID>4</pageID> <menuItem> <pageID>5</pageID> <menuItem> <pageID>6</pageID> </menuItem> </menuItem> </menuItem> </menuItem> <menuItem> <pageID>3</pageID> ...

Need help with strange Excel behavior
Hi everyone, A workbook that I put together started behaving strange. some of the sheets have cells that have formulae that link them to different sheets (but within the same workbook). I found that some (maybe all, not sure) of the cells that refered to other cells were not showing the updated data. For example I had updated some cells with new numbers. The cells that were refering to this newly updated cells were still showing the previous numbers !! But if I clicked in the formula bar of these cells and without changing the formula, hit enter, it now suddenly "reads" the...

How to Avoid Dividing by 0 errors in query
I have been getting 'Overflow' errors when trying to run a query. I found out it is because some of my data has a divisor of 0 (e.g. 10/0). This data comes from linked Excel worksheets with hundreds of rows of data. Is there an IF statement or something I can add to the query in the dividing column that can just return a blank (instead of the #Error)? I need this query to feed into another query that I am getting the 'Overflow' error on. Iif([Divisor]=0,0,[MyField]/[Divisor]) MH "Jason52" <Jason52@discussions.microsoft.com> wrote in message news:8DA...

Excel Query #3
I have a large excel spreadsheet that contains skills and skill levels of consultants. Is it possible to create some kind of form within Excel that has a Skills drop down box at the top. When you select the skill you require it looks at the data and displays only the people who have that skill and the skill level? Thanks, Hi, Alison. Try the autofilter feature; it should work perfectly for your needs: http://www.officearticles.com/excel/using_autofilter_in_microsoft_excel.htm ************ Anne Troy www.OfficeArticles.com "Alison" <Alison@discussions.microsoft.com> wrot...

Delete Queries using Unmatched Query
Reading many helpful responses on this site, but unfortunately none of them seem to remedy my current issue. Just learning Access, took a quick college prep course, got the basics. Now I am expanding freelance. SO the scenarios is my test idea that I have intent to apply on larger scale. I have a database with 15 records... lets say reservations (tbl_reservations) for a hotel. Used a maketable to copy that table because it gets updated often to cancelled or complete status. So I filter out the 9 of those 15 reservations which are still in pending status and make the new table (tbl...

Please Help with Excel and Macros
Please help............................ Any help is very appreciated. ---------------------------------------------- The result I would like now is as follows. Data entered in column A will be changing. Data in column B will be static. It should first check cell B2 to see if a matching value in found in the range of cells A2:A28 Should make a Z in C2 if a matching value is found in the range of cells A2:A28. and add the current date to the respective row in column C. This is the case, found it in A2, so it makes a Z in C2 and add the current date in cell D2 (see the example). Should m...

XPath pb
Hi In infopath, I use a XPath expression to get some nodes : var oEMailNodeList = XDocument.DOM.selectNodes("//Message/EMail"); My problem is that this method returns 0 items. Here is the DOM.xml property : <?xml version="1.0" ?> <?mso-infoPathSolution productVersion=\"11.0.5329\" PIVersion=\"\" href=\"file:///C:\Documents%20and%20Settings\t-stevbe\Local%20Settings\Appli cation%20Data\Microsoft\InfoPath\7ab6e8af39fc42e2\manifest.xsf\" solutionVersion=\"\" initialView=\"messagesList\" ?> <?...

please help....
been trying to find how i can get office microsoft publisher,word,excel,templates and i own a windows 98 SECOND EDITION machine...I know it is somewhere yet i dont know where to look to find it...Can you please assist me in where i may locate on how to find it?Would like to download this too my system...Did have a windows 98 at the office i use to work at and we had microsoft there so i do believe it is somewhere.. thank you...kittenjasmine KittenJasmine, The only way you have Office is if you paid for it. It has nothing to do with which version of Windows that is installed on your compu...

Any help with a Firewall/NAT problem?
Hoping someone might be able to help... I have two mail servers sitting behind a Watchguard firewall. I've set up a service which allows me to bind an externally routed IP address to an internal address. I've set up MX records for both servers and pointed at the appropriate address. One of these mail servers is an Exchange (the New one) and the other is an Imail server (the old one). Each server can send and receive mail just fine to any FQDN. The problem is they can't send mail between them. They can't talk to each other. I've even added static entries in the HOSTS...

Help with NPV!
Please Help ASAP! I have been working with the NPV function in excel, and I have run into a problem with regards to the "Frequency" of cash flows. I need to build an automated worksheet that will derive the NPV of 6 different cash flows, each with a variable number of years. i.e. on a financial calculator, after you enter an amount for a cash flow you also enter the number of years that cashflow remain constant for. Excel wants me to enter each cash flow, but if i want Cashflow 4 to last for 2 (or 3 or 99) years instead of 1 (before the other payments are calculated!), I want it to ...

Please Help With Small VBA Problem...
I know I am overlooking something small, but I just cant seem to get a variable (or for that matter the result of a function) from one sub to another. Thats probably not very clear so I am including the relevant portions of code.... Sub WhatToDoWithIt(qCell As Range, qColor As Integer) 'On Error Resume Next Dim AnsWhat As String, ColHeader As String, NumShts As Integer, HeaderRow As Integer, HdrNumOfColumns As Integer HeaderRow = GetHdrRow(ActiveSheet) <<<<<<<<<<<<<<<<<<<<Problem is here, can not get results from function on ...

Query/Report Question
I am creating a construction diary database and I am having some difficulty calculating my number of working days, and would appreciate any insight into what I need to do. I have a fixed beginning date (notice to proceed date) that I have in a table related to other project information. In a data entry form I have a check box to be used if the work day will not be counted (noworkday). I know the formula for the will be working days = report date - beginning date + sum of noworkday. My report will be based on a date range, so how can get the sum of noworkday for each date of the repo...

Help with EXCEL please !!!!
What I am trying to do is open two spreadsheets in excel but I would like them to open in two different excel applications not in the same application. In other words two different excel windows. Is this possible ? Thanks Assuming you don't want two separate instances of the Excel application, but you want the two workbooks open in separate windows that display on the Taskbar... Try this: From the Excel main menu: <tools><options><view> Check: Windows in Taskbar Does that help? *********** Regards, Ron XL2002, WinXP "r_huey@hotmail.com" wrote: > W...

Public Folder Replication. Help
When I try and create a replica on exchange server EX-3 the folder shows up but not the content. If I right click the folder in the Public Folder Tree and select replicate content I get a window where I can choose source and destination. In source I choose EX-1 and in the destination I choose EX-3. This generates a Backfill Replication message. If I track this message it goes to EX-2 and stops. It never makes it to EX-3. Please reveiw details below. All Exchange servers are running 2003 w/sp1. I have 2 Sites in site "A" there is one server(EX-1) which contains the only Public Fold...

How to pass a Nodeset to an XPath extension function?
I am using the .NET framework v2.0.40607 with Visual C# Express and I would like to create some custom XPath functions to use directly in a XSLT stylesheet. I called System.Xml.Query.XmlArgumentList.AddExtensionObject(string, object) to register the functions I've written. The functions that take a String, Boolean or Number parameter work perfectly. However, I do not know how to create a function that will accept a Nodeset as a parameter. I tried writting a function taking a XPathNavigator object, but it does not work for all XPath queries that return a Nodeset: I get an error &qu...

Can I have in Excel SQL query computed constants like "? as Col1"
Trying to have a query that can set a constant in the select statement, for example: SELECT Author, '11/15/2005' as Updated, PublishDate FROM Author WHERE Author like 'A*' Can I prompt the user for this value as an input, for example: SELECT Author, ? as Updated, PublishDate FROM Author WHERE Author like 'A*' Maybe with a prompt "Please enter Updated date". Before resorting to VBA or Access, just want to see if it can be done in Excel. ...

Addition to Query
I want to add this to my Query: if [tblHorseInfo,Status] shows "Finished" to show "Finished" In [TableHorseInfo,StatusDate] SELECT tblHorseInfo.HorseID, tblHorseInfo.Status, funGetHorse(0,tblHorseInfo.HorseID,True) AS Expr1, funGetHorse(0,tblHorseInfo.HorseID,False) AS Name, funGetHorse(0,tblHorseInfo.HorseID,False) AS Expr2, tblHorseInfo.Invocing, tblHorseInfo.StatusDate FROM tblHorseInfo ORDER BY tblHorseInfo.Status, funGetHorse(0,tblHorseInfo.HorseID,True); Thanks for any help on this...............Bob Bob, there is a problem here with data types. If you ...

Run query before closing database
I am using Access 2002. I have a user who needs to do Adhoc reporting and I want to keep her out of my tables. I have a macro that runs on the AutoExec to transfer the database tables from the original to a new database so she can do whatever she wants to create reports. I also have a SQL that will drop all the tables when it's run. I don't want the user to be responsible for running this query. I just want it to run when she closes the database. Is this possible? Is there something on close like the AutoExec on opening a database? Thanks for the help. Ann wrote...