Sorry if I am unnecessarily wordy. I need fast answers. I am new here. This is my first post. Any gaffe is NOT intentional
Hello all. I am having serious issues with a project that I am handling. The client makes request to the server, and the server obliges by sending the date (in XML of course). No problem here at all. The client (written in VB) is supposed to make changes (adding more data in fact) and send it back to the server. Here is where the problem is.

This is the strategy I used. The VB client creates ADO records and adds the extracted data from the XML for the purpose of adding and editting. For new records, new nodes are created. Here is where I am having issues: Element Content is invalid according to the DTD\schema. The code compares the ADO records with entries in the XML tree. If they are found, it simply updates the values. For those that are NOT found, it creates nodes and then updates the nodes with values form the ADO records. This is where the issue lies.

Here is the relevant part of the code where the problem is:

Private Sub SaveOtherInfo(DOMDocument As MSXML2.DOMDocument, Nodestring As String, _
TagName As String, ADORecordset As adodb.Recordset)

Dim loRows As IXMLDOMNodeList, loRow As IXMLDOMNode, NewNode As IXMLDOMNode, _
loFields As IXMLDOMNodeList, loField As IXMLDOMNode, _
Found As Boolean, oTemplate As IXMLDOMNode ', Okay As Boolean
Set loRows = DOMDocument.selectNodes(Nodestring)

' The above is the set of records (the table)
ADORecordset.MoveFirst
' Start at the top
While Not ADORecordset.EOF
Found = False
'Okay = False
For Each loRow In loRows
Set loFields = loRow.childNodes
For Each loField In loFields
If LCase(loField.nodeName) = "code" Then
' This is the field we are interested in
If loField.Text = ADORecordset.fields(loField.nodeName).Value Then
Found = True
End If
Exit For
End If
Next

' Up to here, it is either found or not
If Not Found Then

'FOR ANYBODY WHO WANTS TO HELP, THIS IS WHERE I THINK THE PROBLEM IS. PLEASE LET'S PAY CLOSE ATTENTION
If oTemplate Is Nothing Then
' It has not been created. We purposely put this code here so that
' the code will be created only when it is neccessary
Dim ParentNode As IXMLDOMNode
Set ParentNode = DOMDocument.selectSingleNode(Nodestring)
Set oTemplate = DOMDocument.createElement(TagName)
ParentNode.appendChild oTemplate
' Create object variable that will be used to loop thru
' the name in the ADORecordset
Dim EachField As adodb.Field
' Go thru the field name to create the nodes
For Each EachField In ADORecordset.fields
Set loField = DOMDocument.createElement(EachField.Name)
'loField.Text = ADORecordset.fields.Item(EachField).Value
loField.Text = ADORecordset.fields(loField.nodeName).Value
oTemplate.appendChild loField
Next
End If

' Loop thru all the fields and create them
' That is why we created the template that will be used
Else
For Each loField In loFields
loField.Text = ADORecordset.fields(loField.nodeName).Value
Next
End If
ADORecordset.MoveNext
loRows.nextNode
If ADORecordset.EOF Then
Exit For
End If
Next
Wend
End Sub

- <PCs xmlns="x-schema:#pcs">
- <PC>
<code type="string" size="4">387</code>
<usercode type="string" size="10">3659384993</usercode>
<year type="string" size="4">1992</year>
<title type="string" size="2147483647">xNational Youth Service Corps (NYSC)</title>
<weight type="string" size="1">5</weight>
<deleteit type="boolean" size="1">0</deleteit>
- <PC xmlns=""> THIS SHOULD NOT BE THIS INDENTED. IT MAKES IT TO BE A CHILD NODE OF THE FIRST <PC>
<code>737</code> NOTICE THAT THE ATTRIBUTES SUCH AS <code type="string" size="4"> ARE MISSING. HOW DO I DO THIS?
<usercode />
<year>2000</year>
<title>MCSE</title>
<weight>5</weight>
<deleteit />
</PC>
</PC>
</PCs>

I will appreciate assistance from any quarters. Thanks in anticipation of your kind assistance.