title: Validate XML Schema in Delphi received by c# web service as a parameter
body: <p>I have a C# Web Service that returns a XML as a result that will be consumed by a Delphi 7 application. Normally, I would return a .Net XmlDocument class if I had a .Net client, but, for Delphi, I'm returning a string. Below is the C# Web Service Code:</p>
  
  <pre><code>public String ReturnXML()
  {
      XmlDocument xmlDoc = GenerateXmlMethod();
      String sXmlResult = String.Empty;
      if (xmlDoc != null)
      {
          using (StringWriter oXml = new StringWriter())
          {
              xmlDoc.Save(oXml);
              sXmlResult = oXml.ToString();
          }
      }
      return sXmlResult;
  }
  </code></pre>
  
  <p>In Delphi, I got the code below from another question <a href="https://stackoverflow.com/questions/446635/schema-validation-with-msxml-in-delphi">here</a> at StachOverflow, and it works perfectly if I had to load the XML and XSD from disk, but I need to load it from memory. Below is my Delphi code now:</p>
  
  <pre><code>procedure TfrmTestador.Button3Click(Sender: TObject);
  var
    XML, XSDL, XSDLDom: Variant;
  begin
    XSDLDom := CreateOLEObject('MSXML2.DOMDocument.6.0');
    try
      XSDLDom.async := false;
      XSDLDom.load('C:\Temp\XsdFile.xsd');
      XSDL := CreateOLEObject('MSXML2.XMLSchemaCache.6.0');
      try
        XSDL.add('',XSDLDom);
        XML := CreateOLEObject('Msxml2.DOMDocument.6.0');
        try
          XML.validateOnParse := True;
          XML.resolveExternals := True;
          XML.schemas := XSDL;
          XML.load('C:\Temp\XmlFile.xml');
          ShowMessage(XML.parseError.reason);
        finally
          XML := Unassigned;
        end;
      finally
        XSDL := Unassigned;
      end;
    finally
      XSDLDom := Unassigned;
    end;
  end;
  </code></pre>
  
  <p>What would be the Delphi code to load the XSD and the XML from WideString variables, and have it working as the code that loads them from file, validating the XML on a fixed XSD schema that is coded into the application? Is there a better way to return the XML from C# so it is read more easily into Delphi?<br>
  Tks for your time!</p>