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 6319737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:51:24+00:00 2026-05-24T15:51:24+00:00

I have two xml documents with about 1000 elements in each of them and

  • 0

I have two xml documents with about 1000 elements in each of them and they both have different schemas. I am trying to map document A to document B and wanted to know what the best method to do this would be.

Currently I am grabbing all the elements from document A then creating a series of XElements to be placed into document B. I am using the values from document A’s XElements to populate the values of document B’s XElements. I then place these newly created XElements into a basic xml document. This document is a stripped down version of document B which only contains the basic elements—kind of like an outer shell. Here is some sample code:

XElement docAName = docA.Descendants(DocANameSpace + "Name").FirstOrDefault();
XElement docBName = new XElement("{http://namespace.com}Name", docAName.Value);
docBTemplate.Descendants(DocBNameSpace + "Names").FirstOrDefault().Add(DocBName);

However, there is so many elements that I wound up with a method of over 1000 lines and it just looks sloppy. Anyone have any suggestions on a better way to map these documents? I don’t know of an XSLT Transformation will work since the schemas are so different.

Edit:I looked into XSL Transform and it sounds like it would be quite a bit of work. The two xml documents are very different and it would require massive restructuring. This isn’t a simple one-to-one replace one elements value with another. I am changing the names, namespaces, locations, hierarchical structure and even some of the values, which have to be slightly altered in order to conform to document B’s schema. It sounds like XSL Transform would be better used when mapping two small documents where you would just need to swap some values and element names. Amy I correct in thinking this?

  • 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-24T15:51:25+00:00Added an answer on May 24, 2026 at 3:51 pm

    If I understand you correctly you want to change a namespace to a different one and strip a few elements?

    I would use an XSLT transform – IMHO the tool for XML-to-XML transformation. How different the schemas are doesn’t matter really, why should it? Making partial copies and applying changes to element namespace is a very simple task in XSLT.

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

Sidebar

Related Questions

I have two XML files with two different XSD schemas and different namespaces. They
I have to merge two xml documents using xslt 1.0. Each xml document has
I have parsed XML using both of the following two methods... Parsing the XmlDocument
I have two XML files. They are similar, but there are two nodes of
I have two applications written in Java that communicate with each other using XML
What is the best/fastest way to merge two xml documents with ruby? I have
I have two documents both are similar but I need to find an elegant
I need to merge two XML documents, overwriting the overlapsed attributes and elements. For
How can I do a Linq query for this? I have two xml documents,
this is my situation: I have two org.w3c.dom.Document created from two xml files. What

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.