Closed imranrasheeddeveloper closed 2 years ago
Hi @imranrasheeddeveloper - I'm not seeing the issue details actually filled out, it looks like it is still just using the template... the title suggests that you're seeing an issue related to 'SWXMLHash' has no member named 'config'
, though.
Do you have a repro set up somewhere that I could look at?
swift version 5 Xcode 12.4
fileprivate func parse() throws -> Group {
let config = SWXMLHash.config { config in
config.shouldProcessNamespaces = true
}
let parsedXml = config.parse(xmlString)
var svgElement: SWXMLHash.XMLElement?
for child in parsedXml.children {
if let element = child.element {
if element.name == "svg" {
svgElement = element
try prepareSvg(child.children)
break
}
}
}
let layout = svgElement != nil ? try parseViewBox(svgElement!) : nil
try parseSvg(parsedXml.children)
let root = layout != nil ? SVGCanvas(layout: layout!, contents: nodes) : Group(contents: nodes)
if let opacity = svgElement?.attribute(by: "opacity") {
root.opacity = getOpacity(opacity.text)
}
return root
}
If you're using the latest version of SWXMLHash, the entry class has been renamed from SWXMLHash
to XMLHash
- see the release up at https://github.com/drmohundro/SWXMLHash/releases/tag/6.0.0.
This was done to fix a specific scenario mentioned in https://github.com/drmohundro/SWXMLHash/issues/242.
I think that might be the fix here. So, in your case, the code should instead look like:
fileprivate func parse() throws -> Group {
let config = XMLHash.config { config in
config.shouldProcessNamespaces = true
}
let parsedXml = config.parse(xmlString)
var svgElement: XMLHash.XMLElement?
for child in parsedXml.children {
if let element = child.element {
if element.name == "svg" {
svgElement = element
try prepareSvg(child.children)
break
}
}
}
let layout = svgElement != nil ? try parseViewBox(svgElement!) : nil
try parseSvg(parsedXml.children)
let root = layout != nil ? SVGCanvas(layout: layout!, contents: nodes) : Group(contents: nodes)
if let opacity = svgElement?.attribute(by: "opacity") {
root.opacity = getOpacity(opacity.text)
}
return root
I'm closing the issue. If you're still having issues, please feel free to comment or re-open.
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Environment:
Additional context Add any other context about the problem here.