Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 10th, 2011, 03:07 PM
Authorized User
 
Join Date: Jul 2010
Posts: 74
Thanks: 23
Thanked 0 Times in 0 Posts
Question How to get the value from the nodes with the same name without any distinguish attr

input xml:
<rootNode>
--<Node>
----<Name1attribute1="1">
----</Name1>
----<Name2 attribute="2">
----</Name2>
----<Lines attribute="Line1" anotherAtt="I need this one">
----</Lines>
----<Lines nm="second" mn="dnoces">
----</Lines>
----<Lines ...>
----</Lines>
----<Lines q="4" p="th">
----</Lines>
----<Lines ...>
----</Lines>
--</Node>
</rootNode>

output xml:
<root>
--<roo>
----<firstLines a="Line1" b="I need this one"/>
--</roo>
--<oor>
----<fourthLines a="4" b="th"/>
--</oor>
</root>

The input xml has many of the same node "Lines", and their attributes are randomly, which means we can not distinguish them via their attribute(s). Now I only need the first "Lines", how can I achieve this?
What about Nth "Lines", let's say 4th "Lines", how can I just get 4th "Lines"?

Thank you in advance.

Last edited by JohnKiller; August 10th, 2011 at 03:23 PM..
 
Old August 10th, 2011, 05:22 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Lines[1] or Lines[4]

http://www.w3schools.com/xpath/xpath_syntax.asp
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
JohnKiller (August 10th, 2011)
 
Old August 10th, 2011, 05:35 PM
Authorized User
 
Join Date: Jul 2010
Posts: 74
Thanks: 23
Thanked 0 Times in 0 Posts
Default

It is so simple!

Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i distinguish refresh or close page by js? Cade_Feng Javascript 10 September 13th, 2010 04:28 AM
How to value in b/n nodes Swetha XSLT 1 May 20th, 2008 12:20 PM
two different templates for same match attr? gabster XSLT 3 September 6th, 2007 10:56 AM
Nodes ....'For Each' problem. Neal XSLT 3 February 13th, 2006 08:57 AM
differentiating between two nodes RazoRmedia XSLT 4 February 9th, 2006 06:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.