473,406 Members | 2,816 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,406 software developers and data experts.

Xml Node exists

Hello,

How can I check if a parameter (node) already exists in my xmldocument?
If it does not exists I have to add it

example:

If ExistsNode("SID") Then
'add the node
End If

I need some help for the "ExistsNode" function

<xml version="1.0">
<parameters>
<parameter>
<paramName>patnr</paramName>
<paramValue>00000</paramValue>
</parameter>
<parameter>
<paramName>SID</paramName>
<paramValue>00898798798798798D8d000</paramValue>
</parameter>
<parameter>
<paramName>GUID</paramName>
<paramValue>0090-JDI900000000-KKKDL000</paramValue>
</parameter>
</parameters>
</xml>

Nov 21 '05 #1
1 6550


Gene Vangampelaere wrote:
How can I check if a parameter (node) already exists in my xmldocument?
If it does not exists I have to add it

example:

If ExistsNode("SID") Then
'add the node
End If

I need some help for the "ExistsNode" function

<xml version="1.0">
<parameters>
<parameter>
<paramName>patnr</paramName>
<paramValue>00000</paramValue>
</parameter>
<parameter>
<paramName>SID</paramName>
<paramValue>00898798798798798D8d000</paramValue>
</parameter>
<parameter>
<paramName>GUID</paramName>
<paramValue>0090-JDI900000000-KKKDL000</paramValue>
</parameter>
</parameters>
</xml>


You can use XPath e.g.
If xmlDocument.SelectSingleNode("/parameters/parameter[@paramName =
'SID']") Is Nothing Then
' Add node

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Boobie | last post by:
Is there any other way to remove a node/element other than going into the Parent and do "removeChild" ? thanks (need to remove a div of id "foobar")
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...
1
by: Siu | last post by:
Hi, in my ASP.NET (C#) application I would like to check in advance if a node exist: my code is as follow: XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(XML_FILENAME); XmlNode...
1
by: Gene Vangampelaere | last post by:
Hello, How can I check if a parameter (node) already exists in my xmldocument? If it does not exists I have to add it example: If ExistsNode("SID") Then 'add the node End If
1
by: Philip Wagenaar | last post by:
I have an XML file that has a date element. I want to change this date to unix notation. This works, but if the XML does not have the element I cannot assign the DateField the value. How can I...
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...
9
by: martymix | last post by:
simple question: I have a simple <dt>test text</dt> I get the innerHTML of that dt, and I try and append some text to it like so: dt = document.getElementsByTagName('dt') var text =...
1
by: Zachary Turner | last post by:
I want to select some nodes based on whether or not another node exists in another part of the document with the exact same name. For example, <special-location> <special-element...
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...
1
by: yousuf20022002 | last post by:
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 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.