Xpath Query #3

Hi All

Couldn't find an xpath specifig UG, so I'm posting this here.

I have XML in the following structure:

<Assignments>
    <Assignment>
        <ID>123</ID>
        <Description>Test Assignment 1</Description>
        <DueDate>2006/10/10</DueDate>
        <Tasks>
            <Task>
                <ID>1</ID>
                <Description>Task 1</Description>
            </Task>
            <Task>
                <ID>2</ID>
                <Description>Task 2</Description>
            </Task>
            <Task>
                <ID>3</ID>
                <Description>Task 3</Description>
            </Task>
        </Tasks>
    </Assignment>
    <Assignment>
        <ID>456</ID>
        <Description>Test Assignment 2</Description>
        <DueDate>2006/10/12</DueDate>
        <Tasks>
            <Task>
                <ID>4</ID>
                <Description>Task 4</Description>
            </Task>
            <Task>
                <ID>5</ID>
                <Description>Task 5</Description>
            </Task>
            <Task>
                <ID>6</ID>
                <Description>Task 6</Description>
            </Task>
        </Tasks>
    </Assignment>
    <Assignment>
        <ID>789</ID>
        <Description>Test Assignment 3</Description>
        <DueDate>2006/10/15</DueDate>
    </Assignment>
</Assignments>

As you can see, not all Assignment Nodes have a Tasks node. I require
an XPATH query that will return all Assignments that have Tasks, but
the result should only contain the Assignment's ID and the Tasks node.
For example, the above XML should be returned as:

<Assignment>
    <ID>123</ID>
    <Tasks>
        <Task>
            <ID>1</ID>
            <Description>Task 1</Description>
        </Task>
        <Task>
            <ID>2</ID>
            <Description>Task 2</Description>
        </Task>
        <Task>
            <ID>3</ID>
            <Description>Task 3</Description>
        </Task>
    </Tasks>
</Assignment>
<Assignment>
    <ID>456</ID>
    <Tasks>
        <Task>
            <ID>4</ID>
            <Description>Task 4</Description>
        </Task>
        <Task>
            <ID>5</ID>
            <Description>Task 5</Description>
        </Task>
        <Task>
            <ID>6</ID>
            <Description>Task 6</Description>
        </Task>
    </Tasks>
</Assignment>

Thanks.

0
9/21/2006 8:24:35 AM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
578 Views

Similar Articles

[PageSpeed] 57

<cobus.lombard@gmail.com> wrote in message 
news:1158827075.562526.103680@i42g2000cwa.googlegroups.com...
> Hi All
>
> Couldn't find an xpath specifig UG, so I'm posting this here.
>
> I have XML in the following structure:
>
....

> As you can see, not all Assignment Nodes have a Tasks node. I require
> an XPATH query that will return all Assignments that have Tasks, but
> the result should only contain the Assignment's ID and the Tasks node.
> For example, the above XML should be returned as:
>
> <Assignment>
>    <ID>123</ID>
>    <Tasks>
>        <Task>
>            <ID>1</ID>
>            <Description>Task 1</Description>
>        </Task>
>        <Task>
>            <ID>2</ID>
>            <Description>Task 2</Description>
>        </Task>
>        <Task>
>            <ID>3</ID>
>            <Description>Task 3</Description>
>        </Task>
>    </Tasks>
> </Assignment>

I think that it isn't an XPath query you need, but rather an XSL 
transformation. This transformation would be driven by an XPath expression 
like //Assignment[Tasks].

John


0
John
9/21/2006 11:02:42 AM
John Saunders wrote:
>
> I think that it isn't an XPath query you need, but rather an XSL
> transformation. This transformation would be driven by an XPath expression
> like //Assignment[Tasks].
>
> John

Hi John, thanks for the reply.

I really was hoping to do this with one XPath expression.
//Assignment[Tasks] is halfway there as it only returns Assignments
that contain Tasks, but it also brings back the entire Assignment Node,
and I only want the ID and the Tasks Node.

Any ideas?

0
9/21/2006 11:44:28 AM

cobus.lombard@gmail.com wrote:

> I really was hoping to do this with one XPath expression.
> //Assignment[Tasks] is halfway there as it only returns Assignments
> that contain Tasks, but it also brings back the entire Assignment Node,
> and I only want the ID and the Tasks Node.

XPath does not change the structure of the of the original document, you 
need a stylesheet to do that.
What you can do with XPath is select the Assignment elements you are 
looking for with one expression, then use relative XPath expressions to 
select the child nodes you are looking for.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
9/21/2006 11:54:56 AM
Reply:

Similar Artilces:

#REF #3
Hi, I'm doing a projection spreadsheet. The new months in diff sheets will be added as and when the actual month passes, ie, up to now i have sheets up to Aug. But in the MAIN sheet, I'm supposed to have months for the whole year up to Dec. Since Sep to Dec don't have equivalent sheets yet, the cells show #Ref since my formula is =Oct!A1. I want to tell the cell to get the amount from "Oct" sheet if there's such a sheet and if not, get the amount from "Sep" sheet. I tried this "=if(Oct!A1="#REF", Sep!A1,Oct!A1)" but it doesn'...

RPC over HTTP/S on Exchange 2003
I have been configuring my single server with exchange to use RPC over https I have followed the instructions in MS guide and another simplified guide at http://www.petri.co.il/configure_rpc_over_https_on_a_single_server.htm Server spec is: Server 2003 standard SP1, Exchange 2003 SP1, XP client SP2 with outlook 2003 sp2 The bottom line is that when testing from the WAN, the outlook client will not connect and say that the exchange server is unavailable. I have a lot of experience configuring rpc over http/s with sbs2003 but this is the first time for server 2003 standard. I have outlook ...

Summing in A Query
Hello, I have a database which fuel records are stored in. The data is stored in two tables. The first records the daily logs that operators use each time they fuel up. It stores their name, the key they used (keylock fuel system - it's ancient) the unit number of the equipment using the fuel, and the amount of fuel they took. The second table stores the month end information retrieved from the key lock print out. It keeps a running total of the amount of fuel taken with each key, and the operator using that key. We have problems making sure all of the fuel is accounted for each mon...

Query fields
Is it possible to write a criteria where the value of an empty field is "0.00"? Background: I have three queries with different customer account groups. Not every salesperson has customer accounts in every accountgroup - so, he will not shown up in that query. But he has accounts included in another query. Now, I would like to get a sum of commission earned by each salesman calculated from all three queries together. Since the salesman has no record in one query the total sum of that specific salesman is not shown. Any idea how to solve that problem? Thanks Klaus On Wed, 29 A...

How to create an "and" rule in Query Based Distribution Groups
Hi, With Exchange 2003 Query Based Distribution groups, is it possible to create an "and" rule? ie, all users who are based in "London" "and" have the first name "John"? Thanks, Curtis. -- Please reply to news group only. Thank you. Sure. (&(attribute1=blah)(attribute2=blah)) http://msdn.microsoft.com/library/en-us/adsi/adsi/search_filter_syntax.asp?frame=true -- Bharat Suneja MCSE, MCT www.zenprise.com blog: www.suneja.com/blog ----------------------------------- "Curtis Fray" <xxx@xxx.com> wrote in message news:OjVc...

Finding all queries which use a table
Hi, Does anyone know of a tool that can scan all queries in a database and find if a certain table is used? I have a table called tblCustomerRollup which is old and outdated. I want to see which of the 500 queries in my database use this table without opeing every single one of them? Thanks, -- Chuck W Chuck Sounds like a variation on Search/Replace. Try searching online for "Database Documenter" as a starting point. A couple of the commercial tools I've used include FMS, Inc.'s Total Access Analyzer and Black Moshannon's Speed Ferret. There are a lot of fr...

Query to hide duplicate records
I recall that this used to easy in previous versions (Unique values only ??), but in 2007, I can't get this to work at all. I have a table with our companie's job numbers in it. The job numbers show up multiple times because of different phases of the project: ProjNum ProjDescription 3077 Univ. of Vermont/UC/LEED 3077 Univ. of Vermont/University Commons: Building Fee 3077 Univ. of Vermont/University Commons: Excess Professiona... I need to jut have a single listing of each project number, otherwise, I get repeated records in the query that looks at this information (which ...

Simple Access counting queries
Hi, hoping someone can help a relative newbie with a pretty simple query. My database (Access 2007) has three tables: Customers Products Purchases (many-to-one links to both of the other tables, this is basically a linking table) I have two simple queries I'd like to get out of this database, but I'm a bit stuck on how to construct the SQL. Any direction you can give me would be helpful. 1. List of all customers who have purchased 2 or more products (or 3 or more products, or 4+, etc.) 2. List of all customers who have purchased both Product A and Product B (or A, B, and C, or B an...

Problem with vba code to export query result in excel
Hi, I have a access report that exports to excel with click of a button after choosing parameters. This works well. However I have to modify couple of fields to utilize formula in the export module. I am not sure how to do this. I am writing the above code which seems to cause problem. I appreciate any help to resolve this issue. Thanks. Code: If lngColumn = 12 Then xlc.Offset(0, lngColumn).Value = =([UnitPrice]*[OriginalShippedQty])/1000 End If It seems the fields UnitPrice and OrigianalShippedQty are not being recognized here Jack wrote: >Hi, >I have a acces...

time formats #3
I have an Excel sheet with a long list of times spent on various projects. The times should all be in minutes and seconds. The first time reads 2:29 and I know that is accurate, for 2 min, 29 seconds. In the formula bar, it reads, 2:29:00 AM. Another...the cell displays 0:40 and I know that is right, for 40 seconds. But in the formula bar, I see 12:40:00 AM I want numbers, but apparently I am looking at times. I tried changing the format. When I check the format for 2:29, it comes up Custom and says it is hh:mm, not mm:ss. I tried changing it to mm:ss, but that changes the displa...

New Computer #3
How do I move my settings, emails, address book, etc... to my new computer. I'm mostly concerned with Outlook because it's the program I use most often. I have an older computer running WIN2K Pro. I purchased a new Dell computer with Windows XP Pro also with Office 2003. Again how do I make my new Outlook have all the information and settings that my old computer has. I do have both computers connected on my home network and they can see each other. But I'm not sure what to copy over. Any help would be very helpful. Thank You, Paul The file you need to copy and re-use up ...

CRM 3.0
Folks Any way that we can assign leads / opportunities / other entities to teams rather than individuals? All the best Hany Hi Hany, Team ownership is not supported in CRM 3.0. Could you describe your scenario, and maybe we could provide some alternatives? Thanks -- Jay Grewal Microsoft Dynamics CRM This posting is provided "AS IS" with no warranties and confers no rights. "Electronic Workplace" <info@electronicworkplace.LoseThisBit.com> wrote in message news:O0cfzAT$FHA.140@TK2MSFTNGP12.phx.gbl... > Folks > > Any way that we can assign leads /...

Importing #3
I had a previous version of Money and just got a new computer with Money 2004. I have a backup disk made with the info from the previous version. How can I import that into the new version? File|Restore?!? <anonymous@discussions.microsoft.com> wrote in message news:075a01c3d169$a360b0a0$a001280a@phx.gbl... > I had a previous version of Money and just got a new > computer with Money 2004. I have a backup disk made with > the info from the previous version. How can I import that > into the new version? ...

Difficult query
Hi, I have a table called WT,contains the fields "Type of call","DateW" and "ID", this table is used to by users to add rows that determine type of calls received in a call center,I want to create a query with the following criteria: 1- To view number of calls received in each type per day. 2- To show the field "Type of call" in this query,even the type that wa not used,and to view number 0 in the count field. 3-Prcentage of each type of call . On Dec 11, 3:52 pm, Pietro <Pie...@discussions.microsoft.com> wrote: > Hi, > I have a tabl...

Report Query in RMS
Is there somewhere that I could get some information as to how the reports in RMS are composed. When you look at the various reports they all seem fairly simple in there basic structure. Are the any examples of how these reports are composed. The //--- Columns ---// iformation seems to be the same in most reports, same as the //--- Title Rows ---//. Setting up the flitters and the TablesQueried I need to understand. I have the schema for 1.2. How do I better understand the following or what do I need to learn. I wish I was in college again and had all the time in the world. //--- Repo...

Debt Reduction Planner #3
The debt reduction planner on my version of Money 01 does not take the minimum payment due into account. It expects me to short some accounts to make bigger payments to other accounts. Obviously that is not feasable, as the late charges for not making the minimum payment would negate any possible savings. Is there a way to fix this so at least the minimum payment is listed? ...

Converting from Lotus 1, 2, 3 docs
I have a user who has a bunch of Lotus 1, 2, 3 spreadsheets that he is trying to convert to Excel. His version of Lotus is old (version 5), his version of Excel is 2000 sp2. The files convert but they are missing pages or headings or other unacceptable qualities. Anyone any advice? Michael If you open the files using Excel and save them to an .xls format in the current version you are losing data? A while back I needed to do this. I wrote an application in VB that loops through the files, opens them using Excel (add a reference in VB to MS Office 10) and then save them in the current ...

Calculating dates #3
Can anyone tell me what I should use (in the way of helper cells) to take any date (mm/dd/yyyy) and turn it into that same month and day for specific year? For instance, turn... 10/12/2009 into 10/12/2010 and 4/6/1998 into 4/6/2010 I'm trying to determine anniversary date based on start date and do it starting in 2010. TIA -- Jordon Try this: =3DDATE(2010,MONTH(A1),DAY(A1)) Assuming your date is in A1. Hope this helps. Pete On Jan 5, 5:35=A0pm, Jordon <jordon@REMOVE~THISmyrealbox.com> wrote: > Can anyone tell me what I should use (in the way of helper cells) > to tak...

Cell References #3
I have 2 separate work sheets. I want to copy the values of cells in work sheet A to cells in Work sheet B. The values in A are separated by at least 4 rows. Cells in B where I want those values are separated by 1 row. How can I copy the values without having to enter each cell reference indivudually in B? Is there a formula to add columns or rows such as cell A1+3 = cell D1 or cell A1 + 3 = cell A4 gman Wrote: > I have 2 separate work sheets. I want to copy the values of cells i > work > sheet A to cells in Work sheet B. The values in A are separated by a > least > 4...

Sent faxes in CRM 3 doesn't show in history
I am reposting this as I've had no answers to my previous post which is now buried in all the other ananswered posts. Surely someone knows the answer to this??? It's pretty fundamental to what customers will want. Anyone??? ------------------------------------------------------------------- I'm using CRM 3 under SBS 2003. When I send a fax using the "New activity / Fax" option within a contact record it sends successfully. . However there is no record of it stored in the contact history? If I check the fax console on the server the fax has been sent (also verifi...

VBA and SQL Query
hi, i use GP 8.0 and i want to make a custom form for a specific need. i cannot use Dexterity for this change so i really need to use VBA. however in the vba form i want to make a few sql select queries to pull client names, and call a table view, and eventually run a few update queries. is that possible to do with VBA in GP 8.0 ? Yes. You need to create an ADO connection and execute through that. Go to Customersource and search for ADO and VBA. Somewhere, I think in one of the demo links, is a file containing sample code that show you how to do this, including use of the retrievegl...

pass through query variables
Hi Guys, I am looking for some help with a pass through query. I have a number of reports that allow users to select values from combo box's and want to know how I can pass this data in a pass through query. I have looked through and searched but seem to just get sites that I have to register to get some details, but do not wish to register elsewhere to get some info. If any has an example or links to any sites that would cover this I would appreciate it. An example of what I would want to pass is [forms]![frmReports].[txtsupplierID] [forms]![frmReports].[txtprod...

MS Query
This is a multi-part message in MIME format. ------=_NextPart_000_0008_01C3998F.CE542560 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Currently I have a number of MS Queries connected to an Oracle DB = through the ODBC. We have had to change the user name and password for = accessing the database so I need to change the queries. How? The ODBC setup on the PC has been changed but each of the queries still = access via the original id, is there a way in the query editor to change = these details? --=20 Regards Dean=20 dkso@ntlworld.com...

Outlook Express address Book #3
My address book is no longer visible. How do I correct the problem. This is a group to support Outlook from the Office group of programs. Outlook Express is a part of Internet Explorer and is a quite different program despite its similar name.. You will probably get a faster and more expert answer if you post this to an outlook express news group. Try posting in one of these newsgroups: microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x microsoft.public.windows.inetexplorer.ie55.outlookexpress for OE 5.5x microsoft.public.windows.inetexplorer.ie6_outlookexpress for OE 6.x ...

Analytical Accounting Error #3
Hi, I am getting the error 'This record has been created since your attempt to create. Changes will not be saved'. This I am getting while I am trying to add additional transaction dimension. Any idea? Ramesh ...