以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 HTML/XHTML/Ajax/Web 2.0/Web 3.0 』  (http://bbs.xml.org.cn/list.asp?boardid=22)
----  [求助]用ASP读不出XML数据  (http://bbs.xml.org.cn/dispbbs.asp?boardid=22&rootid=&id=76472)


--  作者:小小雄鹰
--  发布时间:8/23/2009 12:46:00 PM

--  [求助]用ASP读不出XML数据
<%
        apiUrl="http://www.dianzijipiao.com/XMLDataResult.asp?Str=0$PEK$PVG$2009-08-25$$$F"
        Set http=Server.CreateObject("Microsoft.XMLHTTP")
            http.Open "GET",apiUrl,False
            http.send
            set backXml=http.ResponseXML
        Set Http=Nothing 
        Set xml=Server.CreateObject("Microsoft.XMLDOM")
            xml.Async=true
            xml.ValidateOnParse=False
            xml.Load(backXml)  
            If xml.ReadyState>2 Then
                if xml.parseError.errorCode = 0 then
     set root=xml.documentElement
     LFReponse=root.getAttribute("LFReponse")
     Set Rst=xml.documentElement.childNodes
        %>
  <%  
    For i=0 To (Rst.Length-1)
   with Rst(i)
    Carrier =.getElementsByTagName("CarrierName").item(0).text
   end with
        %>
  <%=Carrier%><br />
  <%
  Next
  end if
  End if:Set Xml=Nothing%>


   航空公司名字不能出现在ASP网页上
那位高手帮忙看下是那里出错了。谢谢


--  作者:Qr
--  发布时间:8/24/2009 10:58:00 AM

--  
没有ASP环境,把返回的XML贴出来看看。
--  作者:小小雄鹰
--  发布时间:8/24/2009 11:08:00 AM

--  
<?xml version="1.0" encoding="UTF-8" ?>
- <LFReponse>
- <ErrorInfo>
  <Code>0</Code>
  <Description>查询成功</Description>
  <TimeSpend>总执行时间234微秒</TimeSpend>
  </ErrorInfo>
- <DataSingle>
  <QueryIndexID>4004309816</QueryIndexID>
  <ResultNum>7</ResultNum>
- <Data>
  <IndexID>4008171871</IndexID>
  <StartPort>PEK</StartPort>
  <EndPort>PVG</EndPort>
  <FlightNo>CA984</FlightNo>
  <PlaneType>321</PlaneType>
  <OffTime>2009-08-25 07:20:00</OffTime>
  <ArriveTime>2009-08-25 09:30:00</ArriveTime>
  <CarrierCode>CA</CarrierCode>
  <ByPass>0</ByPass>
  <Meat>1</Meat>
  <ETicket>1</ETicket>
  <Price>1130</Price>
  <MinPrice>1040</MinPrice>
  <MinTicket>10</MinTicket>
  <MinCab>B</MinCab>
  <MinDisCount>92</MinDisCount>
  <Distance>1178</Distance>
  <CarrierName>中国国际航空公司</CarrierName>
  <StartPortName>北京首都</StartPortName>
  <EndPortName>上海浦东国际机场</EndPortName>
  <TaxPrice>50</TaxPrice>
  <OilPrice>0</OilPrice>
- <CabInfo>
- <Cab>
  <Code>W</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>S</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>P</Code>
  <Count>3</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>A</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>B</Code>
  <Count>10</Count>
  <Price>1040</Price>
  <DisCount>92</DisCount>
  </Cab>
- <Cab>
  <Code>Y</Code>
  <Count>10</Count>
  <Price>1130</Price>
  <DisCount>100</DisCount>
  </Cab>
- <Cab>
  <Code>F</Code>
  <Count>7</Count>
  <Price>1700</Price>
  <DisCount>150</DisCount>
  </Cab>
  </CabInfo>
  </Data>
- <Data>
  <IndexID>4008171788</IndexID>
  <StartPort>PEK</StartPort>
  <EndPort>PVG</EndPort>
  <FlightNo>MU583</FlightNo>
  <PlaneType>340</PlaneType>
  <OffTime>2009-08-25 10:55:00</OffTime>
  <ArriveTime>2009-08-25 13:05:00</ArriveTime>
  <CarrierCode>MU</CarrierCode>
  <ByPass>0</ByPass>
  <Meat>1</Meat>
  <ETicket>1</ETicket>
  <Price>1130</Price>
  <MinPrice>1040</MinPrice>
  <MinTicket>10</MinTicket>
  <MinCab>B</MinCab>
  <MinDisCount>92</MinDisCount>
  <Distance>1178</Distance>
  <CarrierName>中国东方航空公司</CarrierName>
  <StartPortName>北京首都</StartPortName>
  <EndPortName>上海浦东国际机场</EndPortName>
  <TaxPrice>50</TaxPrice>
  <OilPrice>0</OilPrice>
- <CabInfo>
- <Cab>
  <Code>U</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>K</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>I</Code>
  <Count>2</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>D</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>A</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>B</Code>
  <Count>10</Count>
  <Price>1040</Price>
  <DisCount>92</DisCount>
  </Cab>
- <Cab>
  <Code>Y</Code>
  <Count>10</Count>
  <Price>1130</Price>
  <DisCount>100</DisCount>
  </Cab>
- <Cab>
  <Code>C</Code>
  <Count>10</Count>
  <Price>1470</Price>
  <DisCount>130</DisCount>
  </Cab>
- <Cab>
  <Code>F</Code>
  <Count>10</Count>
  <Price>1700</Price>
  <DisCount>150</DisCount>
  </Cab>
  </CabInfo>
  </Data>
- <Data>
  <IndexID>4008171568</IndexID>
  <StartPort>PEK</StartPort>
  <EndPort>PVG</EndPort>
  <FlightNo>MU271</FlightNo>
  <PlaneType>333</PlaneType>
  <OffTime>2009-08-25 13:50:00</OffTime>
  <ArriveTime>2009-08-25 16:00:00</ArriveTime>
  <CarrierCode>MU</CarrierCode>
  <ByPass>0</ByPass>
  <Meat>1</Meat>
  <ETicket>1</ETicket>
  <Price>1130</Price>
  <MinPrice>1040</MinPrice>
  <MinTicket>10</MinTicket>
  <MinCab>B</MinCab>
  <MinDisCount>92</MinDisCount>
  <Distance>1178</Distance>
  <CarrierName>中国东方航空公司</CarrierName>
  <StartPortName>北京首都</StartPortName>
  <EndPortName>上海浦东国际机场</EndPortName>
  <TaxPrice>50</TaxPrice>
  <OilPrice>0</OilPrice>
- <CabInfo>
- <Cab>
  <Code>U</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>Q</Code>
  <Count>6</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>K</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>J</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>D</Code>
  <Count>3</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>B</Code>
  <Count>10</Count>
  <Price>1040</Price>
  <DisCount>92</DisCount>
  </Cab>
- <Cab>
  <Code>Y</Code>
  <Count>10</Count>
  <Price>1130</Price>
  <DisCount>100</DisCount>
  </Cab>
- <Cab>
  <Code>C</Code>
  <Count>10</Count>
  <Price>1470</Price>
  <DisCount>130</DisCount>
  </Cab>
  </CabInfo>
  </Data>
- <Data>
  <IndexID>4008171963</IndexID>
  <StartPort>PEK</StartPort>
  <EndPort>PVG</EndPort>
  <FlightNo>CA934</FlightNo>
  <PlaneType>340</PlaneType>
  <OffTime>2009-08-25 13:55:00</OffTime>
  <ArriveTime>2009-08-25 16:05:00</ArriveTime>
  <CarrierCode>CA</CarrierCode>
  <ByPass>0</ByPass>
  <Meat>1</Meat>
  <ETicket>1</ETicket>
  <Price>1130</Price>
  <MinPrice>1040</MinPrice>
  <MinTicket>10</MinTicket>
  <MinCab>B</MinCab>
  <MinDisCount>92</MinDisCount>
  <Distance>1178</Distance>
  <CarrierName>中国国际航空公司</CarrierName>
  <StartPortName>北京首都</StartPortName>
  <EndPortName>上海浦东国际机场</EndPortName>
  <TaxPrice>50</TaxPrice>
  <OilPrice>0</OilPrice>
- <CabInfo>
- <Cab>
  <Code>S</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>D</Code>
  <Count>3</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>A</Code>
  <Count>4</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>B</Code>
  <Count>10</Count>
  <Price>1040</Price>
  <DisCount>92</DisCount>
  </Cab>
- <Cab>
  <Code>Y</Code>
  <Count>10</Count>
  <Price>1130</Price>
  <DisCount>100</DisCount>
  </Cab>
- <Cab>
  <Code>C</Code>
  <Count>10</Count>
  <Price>1470</Price>
  <DisCount>130</DisCount>
  </Cab>
- <Cab>
  <Code>F</Code>
  <Count>4</Count>
  <Price>1700</Price>
  <DisCount>150</DisCount>
  </Cab>
  </CabInfo>
  </Data>
- <Data>
  <IndexID>4008171778</IndexID>
  <StartPort>PEK</StartPort>
  <EndPort>PVG</EndPort>
  <FlightNo>MU5130</FlightNo>
  <PlaneType>300</PlaneType>
  <OffTime>2009-08-25 19:05:00</OffTime>
  <ArriveTime>2009-08-25 21:05:00</ArriveTime>
  <CarrierCode>MU</CarrierCode>
  <ByPass>0</ByPass>
  <Meat>1</Meat>
  <ETicket>1</ETicket>
  <Price>1130</Price>
  <MinPrice>1040</MinPrice>
  <MinTicket>10</MinTicket>
  <MinCab>B</MinCab>
  <MinDisCount>92</MinDisCount>
  <Distance>1178</Distance>
  <CarrierName>中国东方航空公司</CarrierName>
  <StartPortName>北京首都</StartPortName>
  <EndPortName>上海浦东国际机场</EndPortName>
  <TaxPrice>50</TaxPrice>
  <OilPrice>0</OilPrice>
- <CabInfo>
- <Cab>
  <Code>U</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>Q</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>K</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>I</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>A</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>B</Code>
  <Count>10</Count>
  <Price>1040</Price>
  <DisCount>92</DisCount>
  </Cab>
- <Cab>
  <Code>Y</Code>
  <Count>10</Count>
  <Price>1130</Price>
  <DisCount>100</DisCount>
  </Cab>
- <Cab>
  <Code>F</Code>
  <Count>10</Count>
  <Price>1700</Price>
  <DisCount>150</DisCount>
  </Cab>
  </CabInfo>
  </Data>
- <Data>
  <IndexID>4008171600</IndexID>
  <StartPort>PEK</StartPort>
  <EndPort>PVG</EndPort>
  <FlightNo>MU563</FlightNo>
  <PlaneType>333</PlaneType>
  <OffTime>2009-08-25 19:05:00</OffTime>
  <ArriveTime>2009-08-25 21:10:00</ArriveTime>
  <CarrierCode>MU</CarrierCode>
  <ByPass>0</ByPass>
  <Meat>1</Meat>
  <ETicket>1</ETicket>
  <Price>1130</Price>
  <MinPrice>860</MinPrice>
  <MinTicket>10</MinTicket>
  <MinCab>M</MinCab>
  <MinDisCount>76</MinDisCount>
  <Distance>1178</Distance>
  <CarrierName>中国东方航空公司</CarrierName>
  <StartPortName>北京首都</StartPortName>
  <EndPortName>上海浦东国际机场</EndPortName>
  <TaxPrice>50</TaxPrice>
  <OilPrice>0</OilPrice>
- <CabInfo>
- <Cab>
  <Code>U</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>Q</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>O</Code>
  <Count>2</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>K</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>J</Code>
  <Count>4</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>I</Code>
  <Count>5</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>E</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>D</Code>
  <Count>2</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>M</Code>
  <Count>10</Count>
  <Price>860</Price>
  <DisCount>76</DisCount>
  </Cab>
- <Cab>
  <Code>L</Code>
  <Count>10</Count>
  <Price>900</Price>
  <DisCount>80</DisCount>
  </Cab>
- <Cab>
  <Code>H</Code>
  <Count>10</Count>
  <Price>950</Price>
  <DisCount>84</DisCount>
  </Cab>
- <Cab>
  <Code>B</Code>
  <Count>10</Count>
  <Price>1040</Price>
  <DisCount>92</DisCount>
  </Cab>
- <Cab>
  <Code>Y</Code>
  <Count>10</Count>
  <Price>1130</Price>
  <DisCount>100</DisCount>
  </Cab>
- <Cab>
  <Code>C</Code>
  <Count>10</Count>
  <Price>1470</Price>
  <DisCount>130</DisCount>
  </Cab>
  </CabInfo>
  </Data>
- <Data>
  <IndexID>4008171867</IndexID>
  <StartPort>PEK</StartPort>
  <EndPort>PVG</EndPort>
  <FlightNo>CA986</FlightNo>
  <PlaneType>320</PlaneType>
  <OffTime>2009-08-25 20:00:00</OffTime>
  <ArriveTime>2009-08-25 22:15:00</ArriveTime>
  <CarrierCode>CA</CarrierCode>
  <ByPass>0</ByPass>
  <Meat>1</Meat>
  <ETicket>1</ETicket>
  <Price>1130</Price>
  <MinPrice>1040</MinPrice>
  <MinTicket>10</MinTicket>
  <MinCab>B</MinCab>
  <MinDisCount>92</MinDisCount>
  <Distance>1178</Distance>
  <CarrierName>中国国际航空公司</CarrierName>
  <StartPortName>北京首都</StartPortName>
  <EndPortName>上海浦东国际机场</EndPortName>
  <TaxPrice>50</TaxPrice>
  <OilPrice>0</OilPrice>
- <CabInfo>
- <Cab>
  <Code>S</Code>
  <Count>10</Count>
  <Price>0</Price>
  <DisCount>0</DisCount>
  </Cab>
- <Cab>
  <Code>B</Code>
  <Count>10</Count>
  <Price>1040</Price>
  <DisCount>92</DisCount>
  </Cab>
- <Cab>
  <Code>Y</Code>
  <Count>10</Count>
  <Price>1130</Price>
  <DisCount>100</DisCount>
  </Cab>
- <Cab>
  <Code>F</Code>
  <Count>7</Count>
  <Price>1700</Price>
  <DisCount>150</DisCount>
  </Cab>
  </CabInfo>
  </Data>
  </DataSingle>
  </LFReponse>
--  作者:Qr
--  发布时间:8/24/2009 11:27:00 AM

--  
把getElementsByTagName("CarrierName")改为selectNodes("\\CarrierName")试试,我这里没有ASP环境,不好测试。
--  作者:小小雄鹰
--  发布时间:8/24/2009 11:37:00 AM

--  
谢谢,这样子还是不行。
--  作者:Qr
--  发布时间:8/24/2009 1:29:00 PM

--  
 var Rst = xml.documentElement.childNodes;

 for(var i=0;i<Rst.length;i++){
  //alert(Rst[i].getElementsByTagName("CarrierName")[0].text);//无返回
  var node = Rst[i].getElementsByTagName("CarrierName");
  var n = node.length;
  for(var i=0;i<n-1;i++){
   alert(node[i].text);//正常
  }
 }
以上是javascript的测试结果,故应该是Carrier =.getElementsByTagName("CarrierName").item(0).text的问题


--  作者:Qr
--  发布时间:8/24/2009 1:31:00 PM

--  
用selectNodes同结果,通过。


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
140.625ms