473,461 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to detect a null child element?

I want to do an sql query and if it returns EOF then I want to skip the append child step.
Expand|Select|Wrap|Line Numbers
  1. Set xmldom = New DOMDocument60
  2.  
  3.     xmldom.async = False
  4.     xmldom.validateOnParse = False
  5.     xmldom.resolveExternals = False
  6.     xmldom.preserveWhiteSpace = True
  7.  
  8.         ' Create a processing instruction targeted for xml.
  9.     Set Node = xmldom.createProcessingInstruction("xml", "version='1.0'")
  10.     xmldom.appendChild Node
  11.     Set Node = Nothing
  12.  
  13.     ' Create a processing instruction targeted for xml-stylesheet.
  14.     'Set Node = dom.createProcessingInstruction("xml-stylesheet", _
  15.                                 "type='text/xml' href='test.xsl'")
  16.     'dom.appendChild Node
  17.     'Set Node = Nothing
  18.  
  19.     ' Create a comment for the document.
  20.     Set Node = xmldom.createComment("xml file created using 2.5.3 Software.")
  21.     xmldom.appendChild Node
  22.     Set Node = Nothing
  23.     xmldom.createTextNode (vbNewLine + vbTab)
  24.     ' Create the root element.
  25.  
  26.     Set root = xmldom.createElement(xmlPrefix + "LobbyReg")
  27.     ' Create an attribute for the root element to define the schema
  28.     Set attr = xmldom.createAttribute("xsi:schemaLocation")
  29.     attr.Value = "file:///C:/XML LobbReg.xsd"
  30.     root.setAttributeNode attr
  31.     Set attr = Nothing
  32.     ' Create an attribute for the root element to locate the schema
  33.     Set attr = xmldom.createAttribute("xmlns:xsd")
  34.     attr.Value = "file:///C:/XML"
  35.     root.setAttributeNode attr
  36.     Set attr = Nothing
  37.     ' Create an attribute for the root element to ??schema??
  38.     Set attr = xmldom.createAttribute("xmlns:xsi")
  39.     attr.Value = "http://www.w3.org/2001/XMLSchema-instance"
  40.     root.setAttributeNode attr
  41.     Set attr = Nothing
  42.     root.appendChild xmldom.createTextNode(vbNewLine + vbTab)
  43.     xmldom.appendChild root
  44.  
  45.     ' Create the children elements.
  46.     root.appendChild createSSN(xmldom)
  47.  
The createSSN routine will do the query and may not have a child to append at the last line. Normally, createSSN returns via

Expand|Select|Wrap|Line Numbers
  1.       Set createSSN = SSNNode
  2.       rsSSN.Close
  3.       rsFiler.Close
  4.       Exit Function
  5.  
What can you return is rsSSN.EOF is true?
Nov 19 '10 #1
6 2370
jkmyoung
2,057 Expert 2GB
Why don't you set a temporary variable to the result of createSSN, and check if it's null?
Not sure if I'm missing something here.

You really need to post how you're running the SQL query; that is the important part.
Nov 23 '10 #2
I tried to do
Expand|Select|Wrap|Line Numbers
  1. Set CreateSSN = Nothing
  2. Exit Function  
  3.  
when my query returned eof but my calling function died with that as I recall.
I think I tried this too and it failed:
Expand|Select|Wrap|Line Numbers
  1. Set SSNnode = Nothing
  2. CreateSSN = SSNnode
  3. Exit Function
  4.  
Nov 23 '10 #3
jkmyoung
2,057 Expert 2GB
Where are you running the query? How?
Nov 23 '10 #4
my code was like this
Expand|Select|Wrap|Line Numbers
  1.     strsql = "Select * From cvrSSN Where REPNO = " + "'" + gsRepno + "'"
  2.     rsSSN.Open strsql, cn, adOpenForwardOnly, adLockReadOnly
  3.     '!!check for no records and exit without child elements
  4.     If rsSSN.EOF Then
  5.  
Nov 23 '10 #5
oh and that code was in createSSN function.

I tried all sorts of ways to try to return "Nothing"...
I either got invalid use of object or when I tried to check for Nothing in the calling routine, or invalid procedure call or argument in the function being called.
Nov 23 '10 #6
jkmyoung
2,057 Expert 2GB
try
if rsSSN.RecordCount == 0
Nov 25 '10 #7

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

Similar topics

3
by: Pat | last post by:
Hi all, In contruction of DTD for a scenario, what are the rules/guildelines to determine if certain piece of information should be stated as child element or an attribute? I read some...
2
by: Rob T. | last post by:
Given the following in a stylesheet: #parent { width: 50px; height: 50px; } #child {
1
by: jrmsmo | last post by:
Hi there, I have an interesting problem that maybe you pros can suggest how I solve. I'm working with a third party program that serializes an XML document (it was obviously not designed with schema...
3
by: Robert | last post by:
I have a number of web projects converted from 1.1 to 2.0 in VS2005. I am methodically seeing the error below: The element 'compilation' has invalid child element 'compilers'. List of...
4
by: patrizio.trinchini | last post by:
Hi all, I'm new to XSLT and maybe my problem have a very trivial answer, but I need an expert that point me in the right direction. What I would obtain is to remove all the elements that have a...
1
by: John Bailo | last post by:
I converted an ASP.net project from VS03 to VS05. There is one warning, for web.config: Warning 1 The element 'compilation' has invalid child element 'compilers'. List of possible...
3
by: rlueneberg | last post by:
I want to change the color of an "a" child element inside a table cell via javascript. Is there any way to do that? Ps: there is no id assigned to child elements. I would like to discover the child...
4
by: grbeal | last post by:
How do I test for a child element with xsl if condition? We have a vendor application that outputs an XML file containing records of School Closings due to inclement weather. That XML file gets...
7
by: dweeti | last post by:
Hi, I am trying to display the child element in the DOM, while hiding the parent using JS and CSS, however I cannot find a way to do this. So for example: <body> <div id="Parent"> <div...
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
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.