Skip to content

Commit

Permalink
Parse XML
Browse files Browse the repository at this point in the history
  • Loading branch information
warchimede committed Jan 19, 2021
1 parent 63d1c0b commit dade6b1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Sources/cpd2xcode/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ struct CPD2xcode: ParsableCommand {

func run() throws {
guard FileManager.default.fileExists(atPath: xmlReport),
let xmlDoc = FileManager.default
let xmlRoot = FileManager.default
.contents(atPath: xmlReport)
.map({ try? XMLDocument(data: $0, options: .documentTidyXML) })
.flatMap({ try? XMLDocument(data: $0, options: .documentTidyXML) })
.flatMap({ $0.rootElement() })
else {
print("ERROR XML input")
return
}

print(xmlDoc as Any)
xmlRoot.elements(forName: "duplication").forEach { duplication in
duplication.elements(forName: "file").forEach { file in
print(file)
}
}
}
}

Expand Down

0 comments on commit dade6b1

Please sign in to comment.