IF ChildNode EXIST? (1 Viewer)

irade92

Registered User.
Local time
Today, 01:49
Joined
Dec 26, 2010
Messages
229
Hi
I want to check if this ChildNodes exirst...(fund_code) in the example ...prescription.SelectSingleNode("./issued_drug/fund_code")
Thanks
 

Minty

AWF VIP
Local time
Today, 00:49
Joined
Jul 26, 2013
Messages
10,371
Not much to go on there.

Sample of the code / tables / forms / uploaded zipped copy of stripped-down database all might help.
Assuming it's a Tree-View then perhaps which tree view are you using?
 

irade92

Registered User.
Local time
Today, 01:49
Joined
Dec 26, 2010
Messages
229
Not much to go on there.

Sample of the code / tables / forms / uploaded zipped copy of stripped-down database all might help.
Assuming it's a Tree-View then perhaps which tree view are you using?
I am parsing an XML file..and this XML file sometimes has ChildNodes (fund_code)..and sometimes hasn't..I want to check when has and when has not..because if there is not ChiledNodes (fund_code) I have message End..Debug..and so
 

irade92

Registered User.
Local time
Today, 01:49
Joined
Dec 26, 2010
Messages
229
As soon as you get a battery recharger you will see that I have posted my code.. but in case you are shortsighted please take a close look at this..
..prescription.SelectSingleNode("./issued_drug/fund_code") and check does "fund_code" exits as a childnodes or not..if not do something else..
that is..
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 00:49
Joined
Sep 12, 2006
Messages
15,653
I am not checking the MSXML library but isn't there a .hasChildNodes property for a node. There must be something of that nature.
Without being critical I don't think a half line of code is what was meant by the request "can you post some code please?"
It's not clear whether your code fragment is correct syntactically or not. Does it work? What does it return? Does it return a single node or does it return a set of all of the nodes in the XML file with that prefix? Are you walking a tree, or trying to extract data? It's all germane. Hence it would be useful to see the context of the code fragment.
 

Minty

AWF VIP
Local time
Today, 00:49
Joined
Jul 26, 2013
Messages
10,371
Well I've cleaned my glasses and I can't see any more than I saw before.
I can't see any attempt on how you are checking for a node and do something based on it being there or not.

Luckily, now that we have determined that you are attempting to parse an XML file and I can see more clearly, I found a thing called google, and it found this;


Which recursively will list child nodes until you are bored.
 

irade92

Registered User.
Local time
Today, 01:49
Joined
Dec 26, 2010
Messages
229
Maybe you need more than a cleared glasses...hm..
Maybe this can help you...this is just a line of a code that works perfectly...for example in an XML file with 5 nodes of "prescription" and 5 childnodes of "issued_drug" and 4 childnodes of "fund_code"...so ..one childnode "fund_code" is missing. Doing parsing with for..next..there is no value of one childnodes ie "fund_code" ..There is .hasChildNodes yes...but i need to specify the name of child node..
 

irade92

Registered User.
Local time
Today, 01:49
Joined
Dec 26, 2010
Messages
229
Maybe you need more than a cleared glasses...hm..
Maybe this can help you...this is just a line of a code that works perfectly...for example in an XML file with 5 nodes of "prescription" and 5 childnodes of "issued_drug" and 4 childnodes of "fund_code"...so ..one childnode "fund_code" is missing. Doing parsing with for..next..there is no value of one childnodes ie "fund_code" ..There is .hasChildNodes yes...but i need to specify the name of child node..
in the meantime i solved this with a little trick...since I store value od each childnodes("fund_code") in a variable and then in a table, after storing in a table I initialize variabile to null...so if there is no value of "fund_code" I did Resume Next and go on for next loop..That is
 

Minty

AWF VIP
Local time
Today, 00:49
Joined
Jul 26, 2013
Messages
10,371
Bizarrely, unless I'm mistaken, it wasn't me asking for help in the first place.

I'm sure the omnipotent other members of the forum will appreciate the inciteful solution to your problem...
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 19:49
Joined
May 21, 2018
Messages
8,527
@Minty,
I have an issue with my car, can you tell me exactly what is wrong? Just asking.
 

Minty

AWF VIP
Local time
Today, 00:49
Joined
Jul 26, 2013
Messages
10,371
@MajP Yes of course - it's the long weight. It's too short.
And your throttle widget needs realigning.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 19:49
Joined
May 21, 2018
Messages
8,527
Thanks. I see you crystal ball is up and working again.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:49
Joined
May 7, 2009
Messages
19,237
can you upload a sample xml file?
 

Users who are viewing this thread

Top Bottom