Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create XML within an activeX DLL

Posted on 2002-05-24
7
Medium Priority
?
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 23

Accepted Solution

by:
b1xml2 earned 400 total points
ID: 7032041
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
ID: 7032047
Plus the answer to your question is, (without the brackets)
objXML.appendChild objPI
0
 
LVL 9

Author Comment

by:AlfaNoMore
ID: 7032064
VB stuck those brackets in for me!!! It won't let me do it without them?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 9

Author Comment

by:AlfaNoMore
ID: 7032087
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
ID: 7032090
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
ID: 7032111
better is this

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

Author Comment

by:AlfaNoMore
ID: 7032146
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

715 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