1

I'm new to ASP.NET and started creating a website with basic razor syntax. I'm trying to display a grid with tile-like div elements from a XML file show below. So far I haven't found anything that would work for this.

"/content/content.xml"

<?xml version="1.0" encoding="utf-8" ?>
<categories>
  <home>
    <tile text="Title 1"></tile>
    <tile text="Title 2"></tile>
  </home>
</categories>

"/home.cshtml"

<body>
    @{ razor code or something}
    <div id="page">
        <div id="categories"></div>
        <div id="tiles"></div>
    </div>
</body>

I would like to get the content from the xml file and display it in html like show:

<body>
    <div id="page">
        <div id="categories">Home</div>
        <div id="tiles">
            <div>Title 1</div>
            <div>Title 2</div>
        </div>
    </div>
</body>

Note: this is a simplified version of my code.

1 Answer 1

1

I would suggest using an XSLT transformation to create the desired output from the specific input. Then I would render the specific output as if it was being a string.

Hope I helped!

Sign up to request clarification or add additional context in comments.

2 Comments

I never heard of XSLT, thanks. Though I would still like to know how to get the data from another page like the php include function. Do you know if this is possible?
Glad to help. The include question is another question. Perhaps you should check master pages. Anyway, you should upvote the answer. It is very important for users navigating to your question to identify useful answers. Anyway,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.