Solved

Create XML within an activeX DLL

Posted on 2002-05-24
7
218 Views
Last Modified: 2010-05-18
I have the following short code. It looks fine, but for some reason I'm getting a "Run-time error '438'; Object doesn't support this property or method" on the appendChild() methods.

Anyone know why this isn't working fort me?


Public Function GetPsychometricsXML(GUID As String, RefNo As String) As MSXML2.DOMDocument
    Dim objXML As MSXML2.DOMDocument
    Dim objPI As MSXML2.IXMLDOMProcessingInstruction
    Dim objRoot As MSXML2.IXMLDOMNode
    Dim objNewNode As MSXML2.IXMLDOMNode
    Dim objRS As ADODB.Recordset
    Dim strSQL As String
   
    Set objXML = New MSXML2.DOMDocument
    'objXML.loadXML ("<xml version=""1.0""></xml>")
   
    '// ADD our Processing Instruction: <xml vesion="1.0" />
    Set objPI = objXML.createProcessingInstruction("xml", " version=""1.0""")
    objXML.appendChild (objPI) '<< ERROR HERE!!!
    Set objPI = Nothing
   
    '// CREATE our ROOT NodeSet <RetrievePsychometricsRS />
    Set objRoot = objXML.createNode(NODE_ELEMENT, "RetrievePsychometricsRS", "")
   
    '// CREATE the Experiences NodeSet <Experiences />
   
   
    objXML.appendChild (objRoot)
    Set objRoot = Nothing
   
    Set GetPsychometricsXML = objXML
    Set objXML = Nothing
   
End Function
0
Comment
Question by:AlfaNoMore
  • 4
  • 3
7 Comments
 
LVL 23

Accepted Solution

by:
b1xml2 earned 100 total points
Comment Utility
that cos you are calling a function without accepting a returned value,
Normally to save time this is what I do,

And the code can be streamlined.

  Public Function GetPsychometricsXML(GUID As String, _
    RefNo As String) As MSXML2.DOMDocument
  Set GetPsychometricsXML = New MSXML2.DOMDocument
  With GetPsychometricsXML
    .async = False
    .appendChild .createProcessingInstruction("xml","version='1.0' encoding='iso-8859-1'")
    .appendChild .createElement("RetrievePsychometricsRS")
  End With
  End Function
0
 
LVL 23

Expert Comment

by:b1xml2
Comment Utility
Plus the answer to your question is, (without the brackets)
objXML.appendChild objPI
0
 
LVL 9

Author Comment

by:AlfaNoMore
Comment Utility
VB stuck those brackets in for me!!! It won't let me do it without them?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 9

Author Comment

by:AlfaNoMore
Comment Utility
As usual, top marks...

If I wanted to add nodes within say the RetrievePsychometricsRS node, could I use:

.selectSingleNode("RetrievePsychometricsRS").appendChild .createElement("Something")
0
 
LVL 23

Expert Comment

by:b1xml2
Comment Utility
please notice if there is a space before the "(" . That means that objXML.append is trying to append an object called "(objPI)".

Anyways, try out the code I have posted =)
0
 
LVL 23

Expert Comment

by:b1xml2
Comment Utility
better is this

.documentElement.appendChild .createElement("Hello")
0
 
LVL 9

Author Comment

by:AlfaNoMore
Comment Utility
Sorry mate, but I'm having a nightmare time with this.

This is the function I have at the mo:

Public Function GetPsychometricsXML(GUID As String, _
    RefNo As String) As MSXML2.DOMDocument
   
    Dim objRS As ADODB.Recordset
    Dim strSQL As String
   
    Set GetPsychometricsXML = New MSXML2.DOMDocument
   
    With GetPsychometricsXML
        .async = False
        .appendChild .createProcessingInstruction("xml", " version=""1.0""")
        .appendChild .createElement("RetrievePsychometricsRS")
        .documentElement.appendChild .createElement("Experiences")
        .documentElement.appendChild .createElement("WorkingStyles")
    End With
End Function

It works, and everything's great, but I need to start adding a lot of content within the Experiences NodeSet, and I'm getting into a right mess.

How could I efficiently produce this XML?
    <Experiences>
        <NoOfItems>3</NoOfItems>
        <Items>
            <Item id="1" title="Do you have experience of using a computer keyboard?" elementName="skills_13" value="2">
                <Option id="1" type="radio" value="1" text="Little/no experience" />
                <Option id="2" type="radio" value="2" text="Occasional/some experience" />
                <Option id="3" type="radio" value="3" text="Considerable experience" />
            </Item>
        <Items>
    </Experiences>

I went down your route, but I had this:

        .documentElement.firstChild.appendChild .createElement("NoOfItems")

And then I have to add a value to this! I think it could get out of control pretty quickly!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now