简体   繁体   中英

Swift Vapor SWXMLHash probably SWXMLHash error

I am building a application in Vapor. My website works fine on localhost but on the Heroku doesn't run correctly. I have got a list with elements from xml. Xml is parsing by SWXMLHash. Heroku printing only static header. I cant see any informations about error in server log. Everything need to works fine but not working.

guard let xmlString = response?.body.bytes?.string else {
    throw Abort.custom(status: .badRequest, message: "Could not retrieve xml string")
}

let xml = SWXMLHash.parse(xmlString)
var cars:[Car] = []
for item in xml["findItemsByCategoryResponse"]["searchResult"]["item"].all {
    cars.append(Car(item:item))
    print("1 "+(item["title"].element?.text ?? ""))

}

var table:[Node]=[]
for car in cars {
    table.append(try ["title": car.title,"url": car.auctionUrl,"price":car.price,"imgUrl":car.galeryUrl].makeNode())
}
var nodeTables = try table.makeNode()
return try drop.view.make("index", Node(node: ["cars": nodeTables]))

I was unable to get SWXMLHash working properly on Heroku so I opted to use XML from Zewo instead. I admit that Zewo's XML lib is not as nice to use, nor are the docs as good, as compared to SWXMLHash, but it did not take too much work to make the switch for me and works just fine on Heroku.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM