Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1089341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:12:24+00:00 2026-05-16T23:12:24+00:00

I have a C# Web Service that returns a XML as a result that

  • 0

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:

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 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:

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;

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?
Tks for your time!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:12:25+00:00Added an answer on May 16, 2026 at 11:12 pm

    Your question boils down to code to load the XSD and the XML from WideString variables using "MSXML2.DOMDocument.6.0".

    That question is totally independent of Delphi, as you are using the language independent IXMLDOMDocument/DOMDocument from the Microsoft MSXML2 DOM implementation (which has excellent on-line documentation).

    The loadXML method will load the XML from a string (which complements the load method, that loads it from a URL).

    Your code then will become something like this:

    XSDLDom.loadXML(XsdString);
    ....
    XML.loadXML(XmlString);
    

    BTW: Deepak Shenoy has a nice whitepaper on using XML in Delphi that explains more on how to use the DOM in Delphi.

    –jeroen

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.