[英]Template parse errors: Unexpected closing tag “p”
I want to format XML file in Angular. 我想在Angular中格式化XML文件。 I tried this: 我尝试了这个:
<div class="element-box">
<div class="details-wrapper">
<p><b class="label">Raw Request</b>
<pre>
{{apiattempt.raw_request | xmlBeautyfier }}
</pre>
</p>
</div>
</div>
But I get this error: 但是我得到这个错误:
ERROR in : Template parse errors:
Unexpected closing tag "p". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags ("
{{apiattempt.raw_request | xmlBeautyfier }}
</pre>
[ERROR ->]</p>
<p><b class="label">Raw Response</b>{{apiattempt.raw_response | xmlBeautyfier }}</p>
</div"):
Do you know how I can fix this? 你知道我该怎么解决吗?
The <pre>
tag is a block level element. <pre>
标签是一个块级元素。 When that is placed inside the <p>...</p>
it will act like a </p>
causing it to close and throwing an error when it gets to your </p>
. 当被置于其内的<p>...</p>
它会像一个</p>
使其闭合,当它得到抛出一个错误,你的</p>
Either close the <p>
before your <pre>
or wrap the pre
in a different element if you want it wrapped. 在<pre>
<p>
之前关闭<p>
,或者如果希望将pre
包装,则将其包装在其他元素中。
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p
Refer to: https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags 请参阅: https : //www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags
In HTML: p tag is implicity closed with next element. 在HTML中:p标记被next元素隐式关闭。 So 所以
Solutions (from best the worst): 解决方案(从最好到最坏):
Possible solution to investigate: - XHTML requires explicit closing p tag. 研究的可能解决方案:-XHTML需要显式关闭p标签。 You can try to use XHTML and let us know if it works. 您可以尝试使用XHTML,并让我们知道它是否有效。 Note: this is a bit of an overkill to your problem... bit always good to learn ;-) 注意:这对于您的问题来说有点过大了……学习总是很不错的;-)
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.