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

how to find if a node exists in a given loop

Hi Guys,
I am struck with something in XML.Here it is what I am doing ...
xml format is like
<root>
<user1>
<details>
<firstname>asdf
</firstname>
<lastname>mhmm
</lastname>
</details>
<contact>
<phno>1234567</phone>
<email>yousuf@asdf.com </email>
<contact>
</user1>
<user1>
<details>
<firstname>seconduser
</firstname>
<lastname>second_lastname
</lastname>
</details>
</user1>

I am using XSLT to convert this xml file into other xml file which I can bind it to gridview.

2nd xml file format which i am trying to have is like...
<users>
<user firstname="asdf" lastname="mhmm" phno="1234567" mail="yousuf@asdf.com" />
<user firstname="seconduser" lastname="second_lastname" phno="not on file" email = "not on file " />
</users>

In the 1st xml file I dont have contact loop in some of the user1 loop. I am trying to figure out how can I find if a node exists in the xml file in a loop.
I need to know if contact node is present in the user1 loop or not. please let me know how the XSLT should be to do this task.
-thanks
Aug 27 '07 #1
1 2224
jkmyoung
2,057 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="user1">
  2.   <xsl:choose>
  3.     <xsl:when test="contact"> ... <xsl:when>
  4.     <xsl:otherwise> ... </xsl:otherwise>
  5.   </xsl:choose>
  6. </xsl:for-each>
Aug 28 '07 #2

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

Similar topics

12
by: pillepop2003 | last post by:
Hey! Can anyone give me a hint, how this problem is best implemented: I have a table of users (see below), where every user has one "superior user" (= parent node), this should be a fully...
2
by: hb | last post by:
Hi, I need to check if a node exists in a XmlDocument object before to use SelectSingleNode() to process. I tried with if(XmlNode.SelectSingleNode("ABC")!=null) But this only works when the...
21
by: Imran | last post by:
I have a vector of integers, such as and I want to find out the number which occurs most frequently.what is the quick method. My array size is huge. what I am doing is 1. find out the...
4
by: Mahesh BS | last post by:
Hello, I need to write a query to find out a set of missing number in a given sequence. Eg : a Column in some table has the following data
0
by: b.coolsaet | last post by:
Hi, like the title says simplexml is giving me a "Node no longer exists" error while using the addChild() function. Note that it's not giving an error on the first addChild(); Can somebody...
0
by: jiing | last post by:
Hi all, I want to use sting(the same as Node.Text) to judge if a node exists in TreeView. I've tried several ways, but seems all failed. could anybody help me? Thanks in advance. //My...
4
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; If I have an XPathNavigator object and for a given xpath statement need to know if the node exists, how should I do this? I have found for some xpath functions it returns an empty string if...
3
by: SM | last post by:
I think that simpleXML is the best thing i've seen in PHP5. It's so simple (d'ho!) and easy to use when it comes to reading a simple XML file. The only thing i'm not sure how to achieve is...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.