Ji
Ji copied to clipboard
xPath fails if there's xmlns
Evaluating XPath strings fails if one of the elements is defined with XML namespace. Most of the frameworks offer a method to register namespaces but I found no way for Ji. So I guess many of the common XML/HTML files can't be queried by your xPath function.
Sorry for my late reply. Yeah, that's a problem for parsing XML. Ji was initially created for parsing html, that's why it's not having this functionality. I'd like to add registering namespaces to Ji, if you could help, PR is welcomed! Thx!
let jiDoc = Ji(htmlURL: URL(string: "https://www.ups.com/track?loc=en_US&tracknum=" + trackingNumber + "&requester=WT/trackdetails")!)
let titleNode = jiDoc?.xPath("//*[@id=\"stApp_progressTableContent\"]/div[2]/table")?.first
titleNode is returning nil, is it because it is not using the namespace? Is there a workaround for this?
Edit: My problem was not rendering the JS and has nothing to do with namespace.