I want to show the XML schema on the browser page.
I need to add breakline <br/>
to string to show info.
I tried like this:
<div>
@XMLSchema
</div>
@code {
private string XMLSchema = "<?xml version='1.0'?>"
"<Employee>"
"<Employee>"
"<FirstName>First</FirstName>"
"<LastName>Second</LastName>"
"<ContactNo>1234567890</ContactNo>"
"<Email>[email protected]</Email>"
"<Address><br>"
"<City>City</City>"
"<Street>Street</Street>"
"<StreetNr>1</StreetNr>"
"<HouseNr>1</HouseNr>"
"<Zip>01123</Zip>"
"</Address>"
"</Employee>"
"</Employees>";
}
And this does not work. I know is like text and can't work. Another special has is don't work too.
Is there another way to paste an XML record with fields in "<>" in HTML?
I don't know how I can do this without adding another variable to any single record. Someone can help me?
CodePudding user response:
There are several ways to solve this but the best would be to define the html structor in the html part of the razor file and reference to the variables instead of define it as a string.
To avaoid your '<'
are rendered you need to escape them by <?
. Same for other Special caracters.
This is why your solution not work, the whole string is not rended by the html engine, include the <br>
. But that is good because otherwise also <Address>
and other xml-tags would be rendered.
<div>
<?xml version='1.0'?>"
"<Employee>"
"<Employee>"
"<FirstName>First</FirstName>"
"<LastName>Second</LastName>"
"<ContactNo>1234567890</ContactNo>"
"<Email>[email protected]</Email>"
"<Address><br>quot;
"<City>City</City>"
"<Street>Street</Street>"
"<StreetNr>1</StreetNr>"
"<HouseNr>1</HouseNr>"
"<Zip>01123</Zip>"
"</Address>"
"</Employee>"
"</Employees>"
</div>
CodePudding user response:
I'm not pretty sure I think Code will work fine like this..
<Employee><br/>
<Employee><br/>
<FirstName>"First"</FirstName><br/>