I have a C # web service that returns XML as a result that will be used by a Delphi 7 application. I usually returned the .Net XmlDocument class if I had a .Net client, but for Delphi I would return a string. The following is the C # web service 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;
}
In Delphi, I got the code below from another question here on StachOverflow, and it works fine if I had to load XML and XSD from disk, but I need to load it from memory. Below is the code of my Delphi:
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;
Delphi XSD XML WideString , , XML XSD, ? XML #, Delphi?
Tks !