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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:31:44+00:00 2026-06-18T05:31:44+00:00

Background I need to transform an XML Document to an XHTML document for conversion

  • 0

Background

I need to transform an XML Document to an XHTML document for conversion to a DOCX in a MVC3 web application. I will be merging in paragraph text around the XML data. The Paragraph text is extracted from a DB. In the past I would have certainly use XSLT to transform the XML. However I now realise that Razor provides a very compelling/better alternative. My XSLT is a little rusty now, and I will be using Razor heavily in my MVC application anyway. So is Razor the way to go?

If razor is the way to go then I would grateful as to how one would include this in say the controller. My initial pseudocode thoughts are along the line of:

  ViewBag.MyXMLDoc = DocXML;    
  var MyDocXHtml = View("XHtmlRazorRenderer", ParagraphTextListModel);

Thoughts greatly appreciated.

Edit

MyDocument = MyDocument.LoadXML("MyDocXML.xml")    
ViewBag.MyDocument = MyDocument;
var MyDocXHtml = View("XHtmlRazorRenderer", ParagraphTextListModel);
  • 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-18T05:31:45+00:00Added an answer on June 18, 2026 at 5:31 am

    Maybe you can create a ViewModel that mimic the structure of your XML.

    That way… you don’t rely on ViewBag… and can loop throught the viewmodel properties and collections to generate the HTML using Razor.

    The creation of the viewmodel should be made on the controller, loading the XML and then using xpath load the viewmodel.

    Then, in Razor, using the ViewModel you generate the HTML.

    Hope your XML is not too complex.

    Your ViewModel:

    public class MyViewModel{
       public ParsedXMLDoc myXmlData {get; set;}
       public ParagraphTextListModel paragraph {get; set;}
    }
    

    In your Controller just pass the MyViewModel to the view as the Model.

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

Sidebar

Related Questions

I come from a .NET background and need to do a web project in
When i send my application to the background i need to kill the process,
I need change background of all text that have two spaces from the start
Background We need to develop a specialised CMS (internal use only) to support a
I need background transparent only for black div. but it is applying even for
Background: What I need to accomplish is to remove any records in a collection
I need to have background Music in my website, With user oN and OFF
I need to know how to change background of expanded list item when it
I need to place two repeated background images on the left and right border
I need to animate my background which have 6 images and that needed to

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.