Avatar of newbie29
newbie29
 asked on

xml dom object required error

Folks,
I am trying to load xml using xml dom and updating few of its node, however, there seems to be some problem in the script, can someone please have a look and see if i am doing anything wrong.
any help is much appreciated
regards
sam
ASPXML

Avatar of undefined
Last Comment
hielo

8/22/2022 - Mon
newbie29

ASKER
<font face="Arial" size=2>

<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a01a8'</font>

<p>

<font face="Arial" size=2>Object required: 'oXMLDoc.DocumentElement'</font>

<p>

line 57-->  Set oParentNode = oXMLDoc.documentElement.selectSingleNode(oReferenceNode)
 oReferenceNode = "//record/ehaus/"
        Set oParentNode = oXMLDoc.documentElement.selectSingleNode(oReferenceNode)
           For i = 0 To UBound(aFields)
                    Set oNode = oXMLDoc.DocumentElement.selectSingleNode( oReferenceNode & aFields(i))                                
                    If Not oNode Is Nothing Then
                            oNode.text = aValues(i)
                    Else
                            Set oNode = oXMLDoc.createElement(aFields(i))
                            oNode.text = aValues(i)
                            oParentNode.appendChild(oNode)
                    End if
            Next
        
        Set oUpdatedNode = oXMLDoc.DocumentElement.SelectSingleNode( oReferenceNode & "eh_last_updated")
            If Not oUpdatedNode Is Nothing Then
                    oUpdatedNode.Text = Year(Now()) & PadZ(Month(Now()),2) & PadZ(Day(Now()),2) 
            Else    
                    Set oUpdatedNode = oXMLDoc.createElement("eh_last_updated")
                    oUpdatedNode.Text = Year(Now()) & PadZ(Month(Now()),2) & PadZ(Day(Now()),2) 
                    oParentNode.AppendChild(oUpdatedNode)                    
         End If

Open in new window

SOLUTION
RobSampson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
newbie29

ASKER
yes i have rob

	   Set oXMLDoc = createObject("MSXML2.DOMDocument")
	   oXMLDoc.async = false
	   oXMLDoc.Load sFullPath
       	
	       aFields = Split(sField, "|")
           aValues = Split(sValue, "|")
           ' This won't handle pipe separated multi-instance fields..
           ' Also - doesn't save tmp copy to Edited folder..
		   
		   oReferenceNode = "//record/ehaus/"
           Set oParentNode = oXMLDoc.documentElement.selectSingleNode(oReferenceNode)
		   
           For i = 0 To UBound(aFields)
                    Set oNode = oXMLDoc.DocumentElement.selectSingleNode( oReferenceNode & aFields(i))                                
                    If Not oNode Is Nothing Then
                            oNode.text = aValues(i)
                    Else
                            Set oNode = oXMLDoc.createElement(aFields(i))
                            oNode.text = aValues(i)
                            oParentNode.appendChild(oNode)
                    End if
            Next
			 	
			'Set oUpdatedNode = oXMLDoc.DocumentElement.SelectSingleNode(oReferenceNode & "eh_last_updated")	
			'If oUpdatedNode Is Nothing Then
			'	Set oUpdatedNode = oXMLDoc.CreateNode(1,"eh_last_updated","")
			'	oXMLDoc.DocumentElement.AppendChild(oUpdatedNode)
			'End If
			'oUpdatedNode.Text = Year(Now()) & PadZ(Month(Now()),2) & PadZ(Day(Now()),2)  
			
			Set oUpdatedNode = oXMLDoc.DocumentElement.SelectSingleNode( oReferenceNode & "eh_last_updated")
            If Not oUpdatedNode Is Nothing Then
                    oUpdatedNode.Text = Year(Now()) & PadZ(Month(Now()),2) & PadZ(Day(Now()),2) 
            Else    
                    Set oUpdatedNode = oXMLDoc.createElement("eh_last_updated")
                    oUpdatedNode.Text = Year(Now()) & PadZ(Month(Now()),2) & PadZ(Day(Now()),2) 
                    oParentNode.AppendChild(oUpdatedNode)                    
            End If 	
			

Open in new window

SOLUTION
bigjokey

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
newbie29

ASKER
hello bigjokey,
thanks for your note, let me try explain what i am trying to do here, from the ajax request i am posting xml node name and its value to process on the server.

all what I wanted to do is the script below and update <feature> if the node exist other create one and update it

this peice of code gets the pipe separated node names and send it to the dom

    aFields="preferences/feature>"
    aValues="N"
'      aFields = Split(sField, "|")
'     aValues = Split(sValue, "|")
      ' This won't handle pipe separated multi-instance fields..
      ' Also - doesn't save tmp copy to Edited folder..
      For i = 0 To UBound(aFields)
            Set oNode = oXMLDoc.DocumentElement.selectSingleNode("//" & aFields(i))
                        
            If Not oNode Is Nothing Then
                  oNode.text = aValues(i)
            Else
                  Set oNode = oXMLDoc.createElement(aFields(i))
                  oNode.text = aValues(i)
                  oXMLDoc.documentElement.appendChild oNode
            End if
      Next


the problem i am having is not been able to  updat/create the node i wanted to ...

error message:
 <font face="Arial" size=2>

<p>msxml3.dll</font> <font face="Arial" size=2>error '80004005'</font>

<p>

<font face="Arial" size=2>This name may not contain the '/' character:

preferences--&gt;/&lt;--feature

</font>

your help is much appreciated
thanks
<record>
<author>S., R. Crockett|Samuel, Rutherford Crockett</author>
<availability>Available</availability>
<preferences>
      <title>test title</title>
      <last_modified>20080411</last_modified>
      <feature>Y</feature>  
<preferences>
</record>

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
hielo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
newbie29

ASKER
thanks hielo
hielo

You are welcome