HtmlElement.OuterHtml Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the current element's HTML code.
public:
property System::String ^ OuterHtml { System::String ^ get(); void set(System::String ^ value); };
public string OuterHtml { get; set; }
member this.OuterHtml : string with get, set
Public Property OuterHtml As String
Property Value
The HTML code for the current element and its children.
Remarks
Whereas InnerHtml will return all HTML contained in the current element excluding the current element's surrounding tags, OuterHtml includes the current element's tag as well as the HTML that tag contains, for example:
<HTML>
<BODY>
<DIV id="div1">
Hello
<DIV id="div2">
World
<DIV id="div3">
How are you?
</DIV>
</DIV>
</DIV>
</BODY>
</HTML>
In this example, calling OuterHtml on div2
will return:
<DIV id="div2">
World
<DIV id="div3">
How are you?
</DIV>
</DIV>
Calling InnerHtml will return:
World
<DIV id="div3">
How are you?
</DIV>
If you assign a new value to OuterHtml, the current element reference will become invalid; it will not reflect the name, properties and child content of the HTML you have just assigned.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈