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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:50:00+00:00 2026-06-13T22:50:00+00:00

I have an XML template file and a previously saved XML database record: XML

  • 0

I have an XML template file and a previously saved XML database record:

  • XML file – contains all the current fields I want for an object – This may change over time with items added
  • XML database record – this is the saved XML. It may be different from the XML in point one because the “template” xml may have been updated to contain more fields, etc.

An example will clear this up..

I have a “template” xml that looks like this:

<dvd displayText="">
  <field id="txtTitle" displayText="true" required="true" type="textbox" width="100" label="DVD Title" />
  <field id="txtDescription" displayText="true" required="true" type="textbox" width="50" label="Your Description" />
</dvd>

This tells the UI to collect a Title and Description when creating a new record. This works perfectly.

So when I create a new DVD record it will display these 2 fields to the user and collect the “Title” and “Description” values and save the value into an XML field in a SQL Server table.

But what I want to do now is add a new “field” definition to the template xml. I’ve done this.. for the purposes of this example, lets have a “PurchasedDate” field definition added to the template XML.

<dvd displayText="">
  <field id="txtTitle" displayText="true" required="true" type="textbox" width="100" label="DVD Title" />
  <field id="txtDescription" displayText="true" required="true" type="textbox" width="50" label="Your Description" />
  <field id="txtPurchaseDate" displayText="true" required="true" type="textbox" width="50" label="Purchase Date" />
</dvd>

If I’m creating a new DVD record, I get prompted for the 3 values; Title, Description, Purchased Date, because that’s whats in the template XML.. But if I’m recalling a previously saved DVD record, it doesn’t have the new “Purchased Date” field in the XML..

<dvd displayText="My DVD">
  <field id="txtTitle" displayText="true" required="true" type="textbox" width="100" label="DVD Title">My Movie DVD</field>
  <field id="txtDescription" displayText="true" required="true" type="textbox" width="50" label="Your Description">This movie is awesome</field>
</dvd>

So what I want to do is take the XML saved in the database (shown above), compare or merge any missing “field” definitions from the template XML file.. and end up with this below:

<dvd displayText="My DVD">
  <field id="txtTitle" displayText="true" required="true" type="textbox" width="100" label="DVD Title">My Movie DVD</field>
  <field id="txtDescription" displayText="true" required="true" type="textbox" width="50" label="Your Description">This movie is awesome</field>
  <field id="txtPurchaseDate" displayText="true" required="true" type="textbox" width="50" label="Purchase Date" />
</dvd>

I’m using Linq to get the value from the existing record from the database if one exists.
and I’m currently doing a XmlDocument.LoadXml(xmlstring) or XmlDocument.Load(filename) depending on whether its new or existing record.

I’d then like to take the XmlDocument and merge the template into this to produce the above XML output for displaying on screen.

If there is a better way than using XmlDocuments, can you please let me know.. I’ll happily go and research it and then use it..

I’m using C#…

Many thanks..

  • 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-13T22:50:01+00:00Added an answer on June 13, 2026 at 10:50 pm

    Your solution has a huge redundancy problem, you will face similar problems if you for instance alters the display text for one of the fields, or change the required field.

    I would separate the metadata from the actual data, i.e. keep one record that describes the fields:

    <dvd displayText="">
      <field id="txtTitle" displayText="true" required="true" type="textbox" width="100" label="DVD Title" />
      <field id="txtDescription" displayText="true" required="true" type="textbox" width="50" label="Your Description" />
      <field id="txtPurchaseDate" displayText="true" required="true" type="textbox" width="50" label="Purchase Date" />
    </dvd>
    

    And strip the data records down to field ids and values:

    <dvd displayText="A movie">
      <field id="txtTitle">Some title</field>
      <field id="txtDescription">Some description</field>
      <field id="txtPurchaseDate">2012-12-21</field>
    </dvd>
    

    Use the meta xml to figure out what fields are possible to load and get the values from the stripped down xml.

    Otherwise you will need to sync all data every time your record layout changes.

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

Sidebar

Related Questions

I have an XML Template file. This file contains a header and some predefined
I have the following XML file. <Record Name=My_Record <Fields StartingBit=0 Size=3 Name=Field_1> </Fields> <Fields
I have an XML file that contains price value.I want to sort my table
I have a XML file template like this that comes from some IC chips,
I have an xml file... <?xml version=1.0 encoding=UTF-8?> <items defaultNode=1> <default contentPlaceholderName=pageContent template= genericContentItemName=
I have a xml template like this <User> <UserId></UserId> <UserName></UserName> <Roles> <Role></Role> <Roles></Role> </Roles>
I have a XML template file like so <?xml version=1.0 encoding=us-ascii?> <AutomatedDispenseResponse> <header shipmentNumber=></header>
I have three files, an xml template, xsl transformation file, and an xsd data
i have created a template xml file witch contain some words like {contentname}. i
I have an XML file that I want to transform using an XSLT. It

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.