Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Replace HTML tags.

$
0
0

I would like to parse my JSON file which contains kay-value pairs and replace tags in my HTML.

So the API gets a JSON file e.g.:

{"myValue1": "value1","myValue2": "value2","myValue3": "value3",
}

and I get a HTML template from DB like:

<!DOCTYPE html><html><head><meta charset=utf-8 /><meta name="description" content="description"><title>Page Title</title><link rel="stylesheet" media="screen" href="css/styles.css" /><link rel="stylesheet" media="print" href="css/print.css" /><style>
body {background:#e3e3e3;}</style></head><body><p style="color: red;">{{myValue1}}</p><p>{{myValue2}}</p><p>{{myValue3}}</p></body></html>

and I would like to replace all tags from JSON file to HTML file and the result should looks like:

<!DOCTYPE html><html><head><meta charset=utf-8 /><meta name="description" content="description"><title>Page Title</title><link rel="stylesheet" media="screen" href="css/styles.css" /><link rel="stylesheet" media="print" href="css/print.css" /><style>
body {background:#e3e3e3;}</style></head><body><p style="color: red;">value1</p><p>value2</p><p>value3</p></body></html>

The template should be replaceable and it is stored in DB. How can I do this in ASP.NET Core?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>