jjzjj

xml - 经典 ASP .loadXML(XMLstring) 读出空白?

coder 2024-07-03 原文

我正在使用经典的 ASP 来解析从 eBay api 发送的 SOAP XML 通知。我正在向自己发布来自 api 文档的测试示例 SOAP 消息。我能够接收 XML 数据字符串。当我将数据转换为字符串并将 xmlString 输出到文本文件时,接收到的 XML 就在那里。

当我将 XML(xmlString) 加载到 DOMDocument 对象并尝试输出它时,我得到的只是 3 个空行。我试图遍历元素并解析它们,但它在 DOM 对象内部似乎是空白的,因为我在查找节点的行中收到 Object Required 错误。

这是我的代码,以及我正在发布的 XML 消息(使用 Postmaster 应用程序),将不胜感激!

<%
Function BytesToStr(bytes)
    Dim Stream
    Set Stream = Server.CreateObject("Adodb.Stream")
        Stream.Type = 1 'adTypeBinary
        Stream.Open
        Stream.Write bytes
        Stream.Position = 0
        Stream.Type = 2 'adTypeText
        Stream.Charset = "iso-8859-1"
        BytesToStr = Stream.ReadText
        Stream.Close
    Set Stream = Nothing
End Function


Dim isPost: isPost = (UCase(Request.ServerVariables("REQUEST_METHOD") & "") = "POST")

'Is it a HTTP POST?
If isPost Then

    If Request.TotalBytes > 0 Then
        Dim lngBytesCount, xmlString
        lngBytesCount = Request.TotalBytes
        xmlString = BytesToStr(Request.BinaryRead(lngBytesCount))


        Dim xdoc
        set xdoc = CreateObject("Msxml2.DOMDocument.6.0")
        xdoc.async = false
        xdoc.loadXML(xmlString)

        call xdoc.setProperty("SelectionNamespaces", "xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='urn:ebay:apis:eBLBaseComponents'")

        '**I commented this next part out because I was getting Error:Object Requred
        '**I couldnt get any XML from xdoc to print at all  
        '**see below: WriteLine(xdoc.xml)    
        'Dim node
        'For Each node in xdoc.selectSingleNode("/soapenv:Body/GetItemResponse").ChildNodes
        '   sResult = sResult & node.xml        
        'Next


        dim fs, tfile
        set fs=Server.CreateObject("Scripting.FileSystemObject")
        set tfile=fs.OpenTextFile("C:\inetpub\wwwroot\ASPtest\_notification3.txt", 8, True)
        tfile.WriteLine(xdoc.xml)
        tfile.WriteLine("")

        tfile.Close
        set tfile=nothing
        set fs=nothing
    End If
  'Let sender know we have received and processing the message.
  Response.Status = "200 OK"
Else
  'Return method not allowed
  Response.Status = "405 Method Not Allowed"
End If
Response.End
%>

发布的示例 SOAP 消息(来自 postman 应用程序):

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://
www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header>
    <ebl:RequesterCredentials soapenv:mustUnderstand="0" xmlns:ns="urn:ebay:apis:eBLBaseComponents"
        xmlns:ebl="urn:ebay:apis:eBLBaseComponents">
      <ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">Z2yhKdKmS0Ga5VPmLDOAlg==</
          ebl:NotificationSignature>
    </ebl:RequesterCredentials>
  </soapenv:Header>
  <soapenv:Body>
    <GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
      <Timestamp>2008-02-13T03:47:28.106Z</Timestamp>
      <Ack>Success</Ack>
      <CorrelationID>137541140</CorrelationID>
      <Version>553</Version>
      <Build>e553_core_Bundled_6057805_R1</Build>
      <NotificationEventName>ItemSold</NotificationEventName>
      <RecipientUserID>Seller1</RecipientUserID>
      <Item>
        <AutoPay>false</AutoPay>
        <BuyerProtection>ItemEligible</BuyerProtection>
        <BuyItNowPrice currencyID="USD">10.0</BuyItNowPrice>
        <Country>US</Country>
        <Currency>USD</Currency>
        <GiftIcon>0</GiftIcon>
        <HitCounter>NoHitCounter</HitCounter>
        <ItemID>250000627102</ItemID>
        <ListingDetails>
          <Adult>false</Adult>
          <BindingAuction>false</BindingAuction>
          <CheckoutEnabled>true</CheckoutEnabled>
          <ConvertedBuyItNowPrice currencyID="USD">10.0</ConvertedBuyItNowPrice>
          <ConvertedStartPrice currencyID="USD">1.0</ConvertedStartPrice>
          <ConvertedReservePrice currencyID="USD">0.0</ConvertedReservePrice>
          <HasReservePrice>false</HasReservePrice>
          <StartTime>2008-02-13T03:42:45.000Z</StartTime>
          <EndTime>2008-02-13T03:43:32.000Z</EndTime>
          <ViewItemURL>http://cgi.qa-api012.qa.ebay.com/ws/eBayISAPI.dll?ViewItem&amp;item=250000627102&amp;category=1463</ViewItemURL>
          <HasUnansweredQuestions>false</HasUnansweredQuestions>
          <HasPublicMessages>false</HasPublicMessages>
          <ExpressListing>false</ExpressListing>
          <ViewItemURLForNaturalSearch>http://cgi.qa-api012.qa.ebay.com/Test-Item-Won-Sold-notify_W0QQitemZ250000627102QQcategoryZ1463QQcmdZViewItem</ViewItemURLForNaturalSearch>
        </ListingDetails>
        <ListingDuration>Days_5</ListingDuration>
        <ListingType>Chinese</ListingType>
        <Location>San Jose, CA</Location>
        <PaymentMethods>PaymentSeeDescription</PaymentMethods>
        <PaymentMethods>PayPal</PaymentMethods>
        <PayPalEmailAddress>ve2@aol.com</PayPalEmailAddress>
        <PrimaryCategory>
          <CategoryID>1463</CategoryID>
          <CategoryName>Collectibles:Trading Cards:Phone Cards</CategoryName>
        </PrimaryCategory>
        <PrivateListing>false</PrivateListing>
        <Quantity>1</Quantity>
        <ReservePrice currencyID="USD">0.0</ReservePrice>
        <ReviseStatus>
          <ItemRevised>false</ItemRevised>
        </ReviseStatus>
        <Seller>
          <AboutMePage>false</AboutMePage>
          <Email>seller@email.com</Email>
          <FeedbackScore>100</FeedbackScore>
          <PositiveFeedbackPercent>98.1</PositiveFeedbackPercent>
          <FeedbackPrivate>false</FeedbackPrivate>
          <FeedbackRatingStar>Turquoise</FeedbackRatingStar>
          <IDVerified>false</IDVerified>
          <eBayGoodStanding>true</eBayGoodStanding>
          <NewUser>false</NewUser>
          <RegistrationDate>2004-02-23T23:50:13.000Z</RegistrationDate>
          <Site>US</Site>
          <Status>Confirmed</Status>
          <UserID>Seller1</UserID>
          <UserIDChanged>false</UserIDChanged>
          <UserIDLastChanged>2004-02-23T23:48:54.000Z</UserIDLastChanged>
          <VATStatus>NoVATTax</VATStatus>
          <SellerInfo>
            <AllowPaymentEdit>true</AllowPaymentEdit>
            <CheckoutEnabled>true</CheckoutEnabled>
            <CIPBankAccountStored>false</CIPBankAccountStored>
            <GoodStanding>true</GoodStanding>
            <MerchandizingPref>OptIn</MerchandizingPref>
            <QualifiesForB2BVAT>false</QualifiesForB2BVAT>
            <SellerLevel>None</SellerLevel>
            <StoreOwner>false</StoreOwner>
            <ExpressEligible>false</ExpressEligible>
            <ExpressWallet>false</ExpressWallet>
            <SafePaymentExempt>true</SafePaymentExempt>
          </SellerInfo>
          <MotorsDealer>false</MotorsDealer>
        </Seller>
        <SellingStatus>
          <BidCount>2</BidCount>
          <BidIncrement currencyID="USD">0.25</BidIncrement>
          <ConvertedCurrentPrice currencyID="USD">1.25</ConvertedCurrentPrice>
          <CurrentPrice currencyID="USD">1.25</CurrentPrice>
          <HighBidder>
            <AboutMePage>false</AboutMePage>
            <EIASToken>nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wJkoWoCJaGoAmdj6x9nY+seQ==</EIASToken>
            <Email>buyer@email.com</Email>
            <FeedbackScore>5</FeedbackScore>
            <PositiveFeedbackPercent>100.0</PositiveFeedbackPercent>
            <FeedbackPrivate>false</FeedbackPrivate>
            <FeedbackRatingStar>None</FeedbackRatingStar>
            <IDVerified>false</IDVerified>
            <eBayGoodStanding>true</eBayGoodStanding>
            <NewUser>false</NewUser>
            <RegistrationDate>2004-02-24T07:00:00.000Z</RegistrationDate>
            <Site>US</Site>
            <Status>Confirmed</Status>
            <UserID>Buyer1</UserID>
            <UserIDChanged>false</UserIDChanged>
            <UserIDLastChanged>2004-02-24T07:00:00.000Z</UserIDLastChanged>
            <VATStatus>NoVATTax</VATStatus>
            <BuyerInfo>
              <ShippingAddress>
                <Country>US</Country>
                <PostalCode>95125</PostalCode>
              </ShippingAddress>
            </BuyerInfo>
            <UserAnonymized>false</UserAnonymized>
          </HighBidder>
          <LeadCount>0</LeadCount>
          <MinimumToBid currencyID="USD">1.5</MinimumToBid>
          <QuantitySold>1</QuantitySold>
          <ReserveMet>true</ReserveMet>
          <SecondChanceEligible>true</SecondChanceEligible>
          <ListingStatus>Completed</ListingStatus>
        </SellingStatus>
        <ShippingDetails>
          <AllowPaymentEdit>true</AllowPaymentEdit>
          <ApplyShippingDiscount>false</ApplyShippingDiscount>
          <InsuranceOption>NotOffered</InsuranceOption>
          <SalesTax>
            <SalesTaxPercent>0.0</SalesTaxPercent>
            <ShippingIncludedInTax>false</ShippingIncludedInTax>
          </SalesTax>
          <ThirdPartyCheckout>false</ThirdPartyCheckout>
          <TaxTable/>
        </ShippingDetails>
        <ShipToLocations>US</ShipToLocations>
        <Site>US</Site>
        <StartPrice currencyID="USD">1.0</StartPrice>
        <TimeLeft>PT0S</TimeLeft>
        <Title>Test Item{Won/Sold} notify</Title>
        <HitCount>0</HitCount>
        <GetItFast>false</GetItFast>
        <PostalCode>
        </PostalCode>
        <PictureDetails>
          <PhotoDisplay>None</PhotoDisplay>
        </PictureDetails>
        <ProxyItem>false</ProxyItem>
      </Item>
    </GetItemResponse>
  </soapenv:Body>
</soapenv:Envelope>

最佳答案

在测试您的代码后,不是 Charset 属性导致了问题(但我会确保它设置为 UTF-8 无论如何) .

问题是 XML 解析失败,在检查 parseError 时发现了这个问题;

-1072896749 - Whitespace is not allowed at this location.

然后我查看了您发布的 XML,其中确实有一些硬包装,我将其移除并再次测试,这次成功了。

修改后的 XML (移除了硬包装)

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header>
    <ebl:RequesterCredentials soapenv:mustUnderstand="0" xmlns:ns="urn:ebay:apis:eBLBaseComponents"  xmlns:ebl="urn:ebay:apis:eBLBaseComponents">
      <ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">Z2yhKdKmS0Ga5VPmLDOAlg==</ebl:NotificationSignature>
    </ebl:RequesterCredentials>
  </soapenv:Header>
  <soapenv:Body>
    <GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
      <Timestamp>2008-02-13T03:47:28.106Z</Timestamp>
      <Ack>Success</Ack>
      <CorrelationID>137541140</CorrelationID>
      <Version>553</Version>
      <Build>e553_core_Bundled_6057805_R1</Build>
      <NotificationEventName>ItemSold</NotificationEventName>
      <RecipientUserID>Seller1</RecipientUserID>
      <Item>
        <AutoPay>false</AutoPay>
        <BuyerProtection>ItemEligible</BuyerProtection>
        <BuyItNowPrice currencyID="USD">10.0</BuyItNowPrice>
        <Country>US</Country>
        <Currency>USD</Currency>
        <GiftIcon>0</GiftIcon>
        <HitCounter>NoHitCounter</HitCounter>
        <ItemID>250000627102</ItemID>
        <ListingDetails>
          <Adult>false</Adult>
          <BindingAuction>false</BindingAuction>
          <CheckoutEnabled>true</CheckoutEnabled>
          <ConvertedBuyItNowPrice currencyID="USD">10.0</ConvertedBuyItNowPrice>
          <ConvertedStartPrice currencyID="USD">1.0</ConvertedStartPrice>
          <ConvertedReservePrice currencyID="USD">0.0</ConvertedReservePrice>
          <HasReservePrice>false</HasReservePrice>
          <StartTime>2008-02-13T03:42:45.000Z</StartTime>
          <EndTime>2008-02-13T03:43:32.000Z</EndTime>
          <ViewItemURL>http://cgi.qa-api012.qa.ebay.com/ws/eBayISAPI.dll?ViewItem&amp;item=250000627102&amp;category=1463</ViewItemURL>
          <HasUnansweredQuestions>false</HasUnansweredQuestions>
          <HasPublicMessages>false</HasPublicMessages>
          <ExpressListing>false</ExpressListing>
          <ViewItemURLForNaturalSearch>http://cgi.qa-api012.qa.ebay.com/Test-Item-Won-Sold-notify_W0QQitemZ250000627102QQcategoryZ1463QQcmdZViewItem</ViewItemURLForNaturalSearch>
        </ListingDetails>
        <ListingDuration>Days_5</ListingDuration>
        <ListingType>Chinese</ListingType>
        <Location>San Jose, CA</Location>
        <PaymentMethods>PaymentSeeDescription</PaymentMethods>
        <PaymentMethods>PayPal</PaymentMethods>
        <PayPalEmailAddress>ve2@aol.com</PayPalEmailAddress>
        <PrimaryCategory>
          <CategoryID>1463</CategoryID>
          <CategoryName>Collectibles:Trading Cards:Phone Cards</CategoryName>
        </PrimaryCategory>
        <PrivateListing>false</PrivateListing>
        <Quantity>1</Quantity>
        <ReservePrice currencyID="USD">0.0</ReservePrice>
        <ReviseStatus>
          <ItemRevised>false</ItemRevised>
        </ReviseStatus>
        <Seller>
          <AboutMePage>false</AboutMePage>
          <Email>seller@email.com</Email>
          <FeedbackScore>100</FeedbackScore>
          <PositiveFeedbackPercent>98.1</PositiveFeedbackPercent>
          <FeedbackPrivate>false</FeedbackPrivate>
          <FeedbackRatingStar>Turquoise</FeedbackRatingStar>
          <IDVerified>false</IDVerified>
          <eBayGoodStanding>true</eBayGoodStanding>
          <NewUser>false</NewUser>
          <RegistrationDate>2004-02-23T23:50:13.000Z</RegistrationDate>
          <Site>US</Site>
          <Status>Confirmed</Status>
          <UserID>Seller1</UserID>
          <UserIDChanged>false</UserIDChanged>
          <UserIDLastChanged>2004-02-23T23:48:54.000Z</UserIDLastChanged>
          <VATStatus>NoVATTax</VATStatus>
          <SellerInfo>
            <AllowPaymentEdit>true</AllowPaymentEdit>
            <CheckoutEnabled>true</CheckoutEnabled>
            <CIPBankAccountStored>false</CIPBankAccountStored>
            <GoodStanding>true</GoodStanding>
            <MerchandizingPref>OptIn</MerchandizingPref>
            <QualifiesForB2BVAT>false</QualifiesForB2BVAT>
            <SellerLevel>None</SellerLevel>
            <StoreOwner>false</StoreOwner>
            <ExpressEligible>false</ExpressEligible>
            <ExpressWallet>false</ExpressWallet>
            <SafePaymentExempt>true</SafePaymentExempt>
          </SellerInfo>
          <MotorsDealer>false</MotorsDealer>
        </Seller>
        <SellingStatus>
          <BidCount>2</BidCount>
          <BidIncrement currencyID="USD">0.25</BidIncrement>
          <ConvertedCurrentPrice currencyID="USD">1.25</ConvertedCurrentPrice>
          <CurrentPrice currencyID="USD">1.25</CurrentPrice>
          <HighBidder>
            <AboutMePage>false</AboutMePage>
            <EIASToken>nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wJkoWoCJaGoAmdj6x9nY+seQ==</EIASToken>
            <Email>buyer@email.com</Email>
            <FeedbackScore>5</FeedbackScore>
            <PositiveFeedbackPercent>100.0</PositiveFeedbackPercent>
            <FeedbackPrivate>false</FeedbackPrivate>
            <FeedbackRatingStar>None</FeedbackRatingStar>
            <IDVerified>false</IDVerified>
            <eBayGoodStanding>true</eBayGoodStanding>
            <NewUser>false</NewUser>
            <RegistrationDate>2004-02-24T07:00:00.000Z</RegistrationDate>
            <Site>US</Site>
            <Status>Confirmed</Status>
            <UserID>Buyer1</UserID>
            <UserIDChanged>false</UserIDChanged>
            <UserIDLastChanged>2004-02-24T07:00:00.000Z</UserIDLastChanged>
            <VATStatus>NoVATTax</VATStatus>
            <BuyerInfo>
              <ShippingAddress>
                <Country>US</Country>
                <PostalCode>95125</PostalCode>
              </ShippingAddress>
            </BuyerInfo>
            <UserAnonymized>false</UserAnonymized>
          </HighBidder>
          <LeadCount>0</LeadCount>
          <MinimumToBid currencyID="USD">1.5</MinimumToBid>
          <QuantitySold>1</QuantitySold>
          <ReserveMet>true</ReserveMet>
          <SecondChanceEligible>true</SecondChanceEligible>
          <ListingStatus>Completed</ListingStatus>
        </SellingStatus>
        <ShippingDetails>
          <AllowPaymentEdit>true</AllowPaymentEdit>
          <ApplyShippingDiscount>false</ApplyShippingDiscount>
          <InsuranceOption>NotOffered</InsuranceOption>
          <SalesTax>
            <SalesTaxPercent>0.0</SalesTaxPercent>
            <ShippingIncludedInTax>false</ShippingIncludedInTax>
          </SalesTax>
          <ThirdPartyCheckout>false</ThirdPartyCheckout>
          <TaxTable/>
        </ShippingDetails>
        <ShipToLocations>US</ShipToLocations>
        <Site>US</Site>
        <StartPrice currencyID="USD">1.0</StartPrice>
        <TimeLeft>PT0S</TimeLeft>
        <Title>Test Item{Won/Sold} notify</Title>
        <HitCount>0</HitCount>
        <GetItFast>false</GetItFast>
        <PostalCode>
        </PostalCode>
        <PictureDetails>
          <PhotoDisplay>None</PhotoDisplay>
        </PictureDetails>
        <ProxyItem>false</ProxyItem>
      </Item>
    </GetItemResponse>
  </soapenv:Body>
</soapenv:Envelope>

这里是帮助调试的修改代码

<%
Option Explicit

Function BytesToStr(bytes)
    Dim Stream
    Set Stream = Server.CreateObject("Adodb.Stream")
    With Stream
        .Type = 1 'adTypeBinary
        .Open
        .Write bytes
        .Position = 0
        .Type = 2 'adTypeText
        .Charset = "UTF-8"
        BytesToStr = .ReadText
        Stream.Close
    End With
    Set Stream = Nothing
End Function


Dim isPost: isPost = (UCase(Request.ServerVariables("REQUEST_METHOD") & "") = "POST")
Dim lngBytesCount, xmlString
Dim xdoc, fs, tfile
Dim loaded

'Is it a HTTP POST?
If isPost Then

    If Request.TotalBytes > 0 Then
        lngBytesCount = Request.TotalBytes
        xmlString = BytesToStr(Request.BinaryRead(lngBytesCount))

        Set xdoc = CreateObject("Msxml2.DOMDocument.6.0")
        xdoc.async = False
        loaded = xdoc.loadXML(xmlString)
        If loaded Then
            Call xdoc.setProperty("SelectionNamespaces", "xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='urn:ebay:apis:eBLBaseComponents'")

            '**I commented this next part out because I was getting Error:Object Requred
            '**I couldnt get any XML from xdoc to print at all  
            '**see below: WriteLine(xdoc.xml)    
            'Dim node
            'For Each node in xdoc.selectSingleNode("/soapenv:Body/GetItemResponse").ChildNodes
            '   sResult = sResult & node.xml        
            'Next

            Set fs=Server.CreateObject("Scripting.FileSystemObject")
            Set tfile=fs.OpenTextFile(Server.MapPath("/files") & "\_notification3.txt", 8, True)
            Call tfile.WriteLine(xdoc.xml)
            Call tfile.WriteLine("")

            Call tfile.Close()
            Set tfile = Nothing
            Set fs = Nothing

            'Let sender know we have received and processing the message.
            Response.Status = "200 OK"
            Response.Write "Message processed"
        Else
            Response.Status = "400 Bad Request"
            Response.Write xdoc.parseError.errorCode & " - " & xdoc.parseError.Reason
        End If
    Else
      Response.Status = "400 Bad Request"
      Response.Write "No message was sent"
    End If
Else
  'Return method not allowed
  Response.Status = "405 Method Not Allowed"
  Response.Write "Requested method is not supported."
End If
Response.End
%>

应该指出,为了测试文件创建,我修改了路径,但您系统上的硬编码路径应该可以正常工作。我对其进行了修改,以便我可以使用 Server.MapPath() 来映射我在网站外部调用 files 的文件夹的物理位置,并为匿名帐户提供所需的权限写信给它。您不必执行任何这些操作,我只是在解释代码看起来不同的原因。

解析 XML

有几点需要指出。

loadXML() 方法返回一个 bool 值,告诉您 XML 是否成功加载。如果返回值为 False,则使用 parseError 对象来检索解析器在验证 XML 时遇到的最后一个错误。

在上面的示例中,我将其作为 HTTP 400 Bad Request 响应传回,并将 errorCodeReason 属性作为请求的主体消息。


相关

关于xml - 经典 ASP .loadXML(XMLstring) 读出空白?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37286592/

有关xml - 经典 ASP .loadXML(XMLstring) 读出空白?的更多相关文章

  1. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

    我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

  2. 7个大一C语言必学的程序 / C语言经典代码大全 - 2

    嗨~大家好,这里是可莉!今天给大家带来的是7个C语言的经典基础代码~那一起往下看下去把【程序一】打印100到200之间的素数#includeintmain(){ inti; for(i=100;i 【程序二】输出乘法口诀表#includeintmain(){inti;for(i=1;i 【程序三】判断1000年---2000年之间的闰年#includeintmain(){intyear;for(year=1000;year 【程序四】给定两个整形变量的值,将两个值的内容进行交换。这里提供两种方法来进行交换,第一种为创建临时变量来进行交换,第二种是不创建临时变量而直接进行交换。1.创建临时变量来

  3. Hive SQL 五大经典面试题 - 2

    目录第1题连续问题分析:解法:第2题分组问题分析:解法:第3题间隔连续问题分析:解法:第4题打折日期交叉问题分析:解法:第5题同时在线问题分析:解法:第1题连续问题如下数据为蚂蚁森林中用户领取的减少碳排放量iddtlowcarbon10012021-12-1212310022021-12-124510012021-12-134310012021-12-134510012021-12-132310022021-12-144510012021-12-1423010022021-12-154510012021-12-1523.......找出连续3天及以上减少碳排放量在100以上的用户分析:遇到这类

  4. ruby - 在 ASP 页面上 Mechanize 中断 - 2

    require'mechanize'agent=Mechanize.newlogin=agent.get('http://www.schoolnet.ch/DE/HomeDE.htm')agent.clicklogin.link_withtext:/Login/然后我得到Mechanize::UnsupportedSchemeError。 最佳答案 Mechanize不支持javascript但您可以将搜索字段添加到表单并为其分配搜索词并使用mechanize提交表单form=page.forms.firstform.add_fie

  5. ruby-on-rails - 如何为空白字段编写 rspec? [Rails3.1] - 2

    我使用rails3.1+rspec和factorygirl。我对必填字段(validates_presence_of)的验证工作正常。我如何让测试将该事实用作“成功”而不是“失败”规范是:describe"Addanindustrywithnoname"docontext"Unabletocreatearecordwhenthenameisblank"dosubjectdoind=Factory.create(:industry_name_blank)endit{shouldbe_invalid}endend但是我失败了:Failures:1)Addanindustrywithnona

  6. ruby-on-rails - 如何在 Rails 3 中禁用 XML 解析 - 2

    我想禁用HTTP参数的自动XML解析。但我发现命令仅适用于Rails2.x,它们都不适用于3.0:config.action_controller.param_parsers.deleteMime::XML(application.rb)ActionController::Base.param_parsers.deleteMime::XMLRails3.0中的等价物是什么? 最佳答案 根据CVE-2013-0156的最新安全公告你可以将它用于Rails3.0。3.1和3.2ActionDispatch::ParamsParser::

  7. ruby - 如何使用 Nokogiri::XML::Builder 生成动态标签? - 2

    我正在遍历数组中的一组标签名称,我想使用构建器打印每个标签名称,而不是求助于“我认为:builder=Nokogiri::XML::Builder.newdo|xml|fortagintagsxml.tag!tag,somevalendend会这样做,但它只是创建名称为“tag”的标签,并将标签变量作为元素的文本值。有人可以帮忙吗?这个看起来应该比较简单,我刚刚在搜索引擎上找不到答案。我可能没有以正确的方式提问。 最佳答案 尝试以下操作。如果我没记错的话,我添加了一个根节点,因为Nokogiri需要一个。builder=Nokogi

  8. ruby - 如何让 Nokogiri 解析并返回 XML 文档? - 2

    这是一些奇怪的例子:#!/usr/bin/rubyrequire'rubygems'require'open-uri'require'nokogiri'print"withoutread:",Nokogiri(open('http://weblog.rubyonrails.org/')).class,"\n"print"withread:",Nokogiri(open('http://weblog.rubyonrails.org/').read).class,"\n"运行此返回:withoutread:Nokogiri::XML::Documentwithread:Nokogiri::

  9. 深度学习12. CNN经典网络 VGG16 - 2

    深度学习12.CNN经典网络VGG16一、简介1.VGG来源2.VGG分类3.不同模型的参数数量4.3x3卷积核的好处5.关于学习率调度6.批归一化二、VGG16层分析1.层划分2.参数展开过程图解3.参数传递示例4.VGG16各层参数数量三、代码分析1.VGG16模型定义2.训练3.测试一、简介1.VGG来源VGG(VisualGeometryGroup)是一个视觉几何组在2014年提出的深度卷积神经网络架构。VGG在2014年ImageNet图像分类竞赛亚军,定位竞赛冠军;VGG网络采用连续的小卷积核(3x3)和池化层构建深度神经网络,网络深度可以达到16层或19层,其中VGG16和VGG

  10. ruby - 模式加载时出现 Nokogiri::XML::Schema SyntaxError - 2

    我正在尝试加载SAML协议(protocol)架构(具体来说:https://www.oasis-open.org/committees/download.php/3407/oasis-sstc-saml-schema-protocol-1.1.xsd),但在执行此操作之后:schema=Nokogiri::XML::Schema(File.read('saml11_schema.xsd'))我得到这个输出:Nokogiri::XML::SyntaxErrorException:Element'{http://www.w3.org/2001/XMLSchema}element',att

随机推荐