OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Help using XMLDOM

[ Lists Home | Date Index | Thread Index ]
  • From: Eddie Shipman <Eddie@acadsoft.com>
  • To: xml-dev@ic.ac.uk
  • Date: Fri, 9 Jul 1999 09:19:20 -0500

When using this code with the MSXML, I get the results below:
{
 This code is Delphi converted from VBScript source at
 http://msdn.microsoft.com/xml/xmlguide/server-getting-data.asp
}

  oXMLDoc := CreateOleObject('Microsoft.XMLDOM');
  // Check to see if a document has data. If it does, don't build it
  if oXMLDoc.ChildNodes.Length = 0 then
  begin
    // Build the XML document
    oRoot := oXMLDoc.CreateNode('element', 'XML','');
    oXMLDoc.AppendChild(oRoot);
    // Queries the database for customer data
    RS.MoveFirst;
    while not RS.EOF do
    begin
      oNode := oXMLDoc.CreateNode('element','Root','');
      oXMLDoc.DocumentElement.AppendChild(oNode);
      for i := 0 to Pred(RS.Fields.Count) do
      begin
        if Length(Trim(VarToStr(RS.Fields[i].Value))) > 0 then
        begin
          oChild := oXMLDoc.CreateNode('element',RS.Fields[i].Name,'');
          iType := RS.Fields[i].Type_;
          case iType of
            adBSTR       : oChild.Text := RS.Fields[i].Value;
            adInteger    : oChild.Text := IntToStr(RS.Fields[i].Value);
            adNumeric    : oChild.Text := IntToStr(RS.Fields[i].Value);
            adSingle     : oChild.Text := IntToStr(RS.Fields[i].Value);
            adBoolean    : if RS.Fields[i].Value then oChild.Text :=
'True' else oChild.Text := 'False';
            adDBTimeStamp: oChild.Text := FormatDateTime('YYYY-MM-DD',
VarToDateTime(RS.Fields[i].Value));
            adChar       : oChild.Text := VarToStr(RS.Fields[i].Value);
            adVarChar    : oChild.Text := VarToStr(RS.Fields[i].Value);
            adLongVarChar: oChild.Text := VarToStr(RS.Fields[i].Value);
          end;
          oNode.AppendChild(oChild);
        end;
      end;
      RS.MoveNext;
    end;
  end;

This is what is returned by the code above:

<XML>
  <Root>
    <CARDNUM>171
    </CARDNUM>
  </Root>
</XML>


I'd like to get something more along the lines of what ADORecordSet.Save
produces when you select the adPersistXML PersistFormat. How would I
modify the code to produce result like this:

<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
 xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
 xmlns:rs='urn:schemas-microsoft-com:rowset'
 xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
 <s:ElementType name='row' content='eltOnly'>
  <s:attribute type='CARDNUM'/>
  <s:extends type='rs:rowbase'/>
 </s:ElementType>
 <s:AttributeType name='CARDNUM' rs:number='1' rs:writeunknown='true'>
  <s:datatype dt:type='number' dt:maxLength='19' rs:scale='0' 
              rs:precision='10' rs:fixedlength='true' 
              rs:maybenull='false'/>
 </s:AttributeType>
</s:Schema>
<rs:data>
 <z:row CARDNUM='171'/>
</rs:data>
</xml>

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS