XMLParse的返回值。我们使用这些track of where we are. Const XML_TOO_MANY_NAMESPACES = -3 ' Too many name space declarations encountered while parsing an element Const XML_NESTED_TOO_DEEP = -2 ' Too many nested XML elements Const XML_SYNTAX_ERROR_OR_FAILED = -1 ' XML syntax error or XMLParse failed Const XML_UNRECOGNIZED_ERROR_CONDITION = 0 ' Unrecognized error condition Const XML_START = 1 ' Start of XML element Const XML_ATTRIBUTE_READ = 2 ' XML attribute read. Const XML_END_OF_ELEMENT = 3 ' End of XML element Const XML_END_OF_DOCUMENT = 4 ' END of XML document encountered. The document has been read/parsed successfully. 'XMLParse max settings Const XML_MAX_DEPTH = 10 Const XML_MAX_NAMESPACES = 3 Public xml_attribute_name As String Public xml_attribute_namespace As String * 100 Public xml_data As String * 3000 Public xml_element_name As String * 50 Public xml_element_namespace As String * 30 Public xml_response_code Public xml_state Public xml_value As String * 50 Public xml_http_header As String * 300 Public xml_http_socket As Long Public pointer As Long Public credit As String * 40 Public credit_URL As String Public suggested_pickup As String * 30 Public suggested_pickup_period Public location As String * 40 Public station_id As String Public latitude As String Public longitude As String Public observation_time As String * 50 Public observation_time_rfc822 As String * 50 Public weather As String Public temperature_string As String Public temp_f Public temp_c Public relative_humidity Public wind_string As String * 40 Public wind_dir As String Public wind_degrees Public wind_mph Public wind_kt Public pressure_string As String Public pressure_mb Public pressure_in Public dewpoint_string As String Public dewpoint_f Public dewpoint_c Public visibility_mi Public two_day_history_url As String * 60 BeginProg Scan(1, Min, 1, 0) xml_http_header = "" xml_http_socket = HTTPGet("http://w1.weather.gov/xml/current_obs/KLGU.xml", xml_data, xml_http_header) TCPClose(xml_http_socket) xml_response_code = XML_START 'Tells XMLParse that we are just starting. While ((xml_response_code > XML_UNRECOGNIZED_ERROR_CONDITION) AND (xml_response_code <> XML_END_OF_DOCUMENT)) xml_response_code = XMLParse(xml_data, xml_value, xml_attribute_name, xml_attribute_namespace, _ xml_element_name, xml_element_namespace, XML_MAX_DEPTH, XML_MAX_NAMESPACES) If xml_response_code = XML_END_OF_ELEMENT Then pointer = 0 'start with clean pointer pointer = @(xml_element_name) 'memory address that pointer points to is variable name with the same name as element name in XML If(pointer > 0) Then !pointer = xml_value 'value of our variable is no set to the value of xml_value EndIf Wend NextScan EndProg
Baidu