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

Bizzare Select single node problem

PT
Hi,
I've a simple XML tree that is essentially.

<?xml version="1.0"?>
<Project>
<Version Version="1.001" />
<Platform Name="Platform1"/>
<Platform Name="Platform2" />
</Project>

Now I have the following code.

XmlNode destinationProjectNode = doc1.SelectSingleNode("//Project");
string xPath = string.Format("{Platform}[@Name='Platform1']");
XmlNode destinationXmlNode = destinationProjectNode.SelectSingleNode(xPath);

This will retrieve the correct node as you'd expect, however in certain
cases and I can't find out why, is the node that is returned has null set
for it's parent, which means it can't be deleted because it thinks it's not
a child of any given node, I checked the body of Project and law and behold
it wasn't there, but, if it's it wasn't there, how did SelectSingleNode pick
it up ?? :/

Any pointers on this would be helpful.

Actually thinking about it, when you do a removechild node, is there
anything else you have to do to remove it from the xml ? as I know when you
bring one node in from a different xml you have to do an importnode and then
an appendchild, so I'm wondering if the node is still lingering around
somewhere but it's actually attached to anything, then again, you'd expect
selectsinglenode not to find it.. sorry, I'm just confused :)

Regards,

PT.

Dec 11 '06 #1
3 3585
PT wrote:
string xPath = string.Format("{Platform}[@Name='Platform1']");
What exactly is that line supposed to do? That does not look right.

If you think you have a problem with the parent node of some node then
consider posting a minimal but complete code sample that allows us to
reproduce the problem.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Dec 11 '06 #2
PT
Sorry about that, I took params off to give a clearer example but forgot to
take the braces off, so should have read.

string xPath = string.Format("Platform[@Name='Platform1']");

I'll try to get a simple sample that busts because it's part of a recursive
procedure, all I know via debugging is that selectsinglenode will return a
node who's parent element is null.
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
PT wrote:
>string xPath = string.Format("{Platform}[@Name='Platform1']");

What exactly is that line supposed to do? That does not look right.

If you think you have a problem with the parent node of some node then
consider posting a minimal but complete code sample that allows us to
reproduce the problem.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Dec 11 '06 #3
PT
as usually the case, post on the forums, fix your own bug :) was a stupid
missing break; command in a loop that scanned attributes.. the shame.

Cheers,

PT

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
PT wrote:
>string xPath = string.Format("{Platform}[@Name='Platform1']");

What exactly is that line supposed to do? That does not look right.

If you think you have a problem with the parent node of some node then
consider posting a minimal but complete code sample that allows us to
reproduce the problem.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Dec 12 '06 #4

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

Similar topics

5
by: Colman | last post by:
Howdy all! I guess I'm a newbie, because I am stumped (or maybe just too durned tired). Here's what I got... CREATE TABLE `nodecat_map` ( `nodecat_id` mediumint(8) unsigned NOT NULL...
5
by: Chris | last post by:
Hi, Maybe I've got a strange question. I've got a XML document (main.xml) with several nodes. Additional I've another XML docuement (role.xml), with allowed nodes. In a XSL-File I just would...
1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
1
by: Zri Man | last post by:
I have come across a bizzare behaviour with DB2/UDB 8.2 on SuSE Linux 2.41 When I have a MQT Refresh going on (complete refresh) it appears to lock the underlying base tables used to build the...
7
by: Martin Pritchard | last post by:
Hi, Sorry for my ignorance, but I'm a bit new to C++. I've been handed over a C++ app written in VS2002 which I have to convert to VS2005. Apparently it's been written in a C style, but cannot...
16
by: Brian D | last post by:
I have a multiple select list that is created dynamically based on a previous selection on an asp page. The first thing I do is to clear the curent option list by ...
5
by: visu | last post by:
Hi this is a question asked in this group two years back.. No answer for this question till date. now i am in the same situation of the questioner.. to find a solution for this problem. Can any...
2
by: naima.mans | last post by:
Hello, i want to select 2 following brothers nodes wich are one under another (one closed to another)... i have done one xslt file... but it's not really good.. for example: the xml file:...
0
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.