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 noaa_air_temperature_f 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 AND xml_element_name = "temp_f" Then noaa_air_temperature_f = xml_value EndIf Wend NextScan EndProg
Baidu