PreferredControlType

HtmlLoadOptions.PreferredControlType property

Obtiene o establece el tipo preferido de nodos de documento que representarán los elementos <input> y <select> importados. El valor predeterminado esFormField .

public HtmlControlType PreferredControlType { get; set; }

Observaciones

Tenga en cuenta que configurar esta propiedad no garantiza que todos los controles importados sean del tipo especificado. Si un control HTML no se puede representar con nodos de documento del tipo preferido, Aspose.Words utilizará un control compatible.HtmlControlType para ese control.

Ejemplos

Muestra cómo establecer el tipo preferido de nodos de documento que representarán los elementos <input> y <select> importados.

const string html = @"
    <html>
        <select name='ComboBox' size='1'>
            <option value='val1'>item1</option>
            <option value='val2'></option>
        </select>
    </html>
";

HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PreferredControlType = HtmlControlType.StructuredDocumentTag;

Document doc = new Document(new MemoryStream(Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
NodeCollection nodes = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);

StructuredDocumentTag tag = (StructuredDocumentTag) nodes[0];

Ver también