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

  • SEARCH
  • Home
  • 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 8220385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:30:06+00:00 2026-06-07T13:30:06+00:00

I have data access method that retrieves xml from database and returns back to

  • 0

I have data access method that retrieves xml from database and returns back to business layer. What should be the return type? Should I simply return them as a string? What is the best practice when returning xml from one layer to another?

I will be returning that xml back to client or may be convert them to json based on client request.

  • 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-06-07T13:30:08+00:00Added an answer on June 7, 2026 at 1:30 pm

    I’d argue that this decision depends on what use cases should cover your method.

    When I’d return a string:

    • Code invoking your method isn’t going to manipulate the result as XML, so why wasting CPU and memory loading a complex object like XmlDocument or XDocument, or whatever? just return a string!

    • Returned XML is a serialized object. You’re going to parse this XML string into an actual .NET object.

    When I’d return an XML object like XDocument or XmlDocument:

    • Code invoking your method is going to manipulate the result as XML. This includes adding new nodes, attributes, or just read some elements or attributes in your XML.

    • Code invoking your method uses some .NET base class library or third-party library that needs an XML object as argument.

    UPDATE

    I forgot to mention the part of “JSON or XML” depending on client request.

    Obviously, if your client needs XML, just return your data as XML, and if your client needs JSON, just return your data as JSON.

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

Sidebar

Related Questions

I have some existing code that retrieves data from a database using ADO.NET that
I have a data access layer, a business logic layer and a presentation layer
I have a data access layer (DAL) that is written in ASP.NET 3.5 and
I have created a Data Access Layer using .NET. Everywhere that I update a
I have a data access library that has a few classes that all implement
I have a data access class that took me a while to get working.
I have data stored as below in an MS Access database: Date User 20090101
I have a .net assembly that contains data access code (a bunch of Typed
I have just started using the Data Access Application Block from microsoft. There are
I have a bit of .NET code that retrieves the results from an Oracle

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.