Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 使用VB.NET提取HTML节点的值_Xml_Vb.net_Saml_Descendant - Fatal编程技术网

Xml 使用VB.NET提取HTML节点的值

Xml 使用VB.NET提取HTML节点的值,xml,vb.net,saml,descendant,Xml,Vb.net,Saml,Descendant,我正在尝试使用VB.NET提取HTML节点的值 表格如下: <html> <head> <title>Submit Form</title> <meta name="referrer" content="origin"/> <meta http-equiv="x-ua-compatible" content="IE=edge" /> </head>

我正在尝试使用VB.NET提取HTML节点的值

表格如下:

<html>
    <head>
        <title>Submit Form</title>
        <meta name="referrer" content="origin"/>
        <meta http-equiv="x-ua-compatible" content="IE=edge" />
    </head>
    <body onload="javascript:document.forms[0].submit()">
       <noscript>
            <p>
                <strong>Note:</strong> Since your browser does not support JavaScript, you must press the Resume button once to proceed.
            </p>
        </noscript>
          <form method="post" action="https://test.aspx">
             <input type="hidden" name="SAMLResponse" value="123456789"/>            
             <noscript><input type="submit" value="Resume"/></noscript>
        </form>
    </body>
</html>
我已经试过了:

Dim SAMLResponse As String = CType(xmlURLDecodedXML.Descendants().Where(Function(x) x.Name.LocalName = "SAMLResponse").FirstOrDefault(), String)

在您的情况下,尝试这样做(假设:SAMLResponse的节点输入不会改变,因为属性位置也会改变):

在html中:

<input type="hidden" name="SAMLResponse" value="123456789"/>

so

The Node Name is input
The First Attribute is Hidden
The Second Attribute is SAMLResponse
The Third Attribute is 123456789

所以
将输入节点名称
第一个属性是隐藏的
第二个属性是SAMLResponse
第三个属性是123456789

我会得到htmlagilitypack,然后您只需执行SAMLResponse=document。选择SingleNode(//input”)。tostring
    Dim myArray() As XElement = MyXelement.Descendants().ToArray
    Dim myname As String = ""
    Dim myValue As String = ""
    For a = 1 To myArray.Count
        If myArray(a - 1).Name.ToString = "input" Then
            Try
                If myArray(a - 1).Attributes.ToArray(1).Value = "SAMLResponse" Then
                    myValue = myArray(a - 1).Attributes.ToArray(2).Value
                End If
            Catch ex As Exception

            End Try
        End If
    Next
<input type="hidden" name="SAMLResponse" value="123456789"/>

so

The Node Name is input
The First Attribute is Hidden
The Second Attribute is SAMLResponse
The Third Attribute is 123456789