
XMLReader::fromStream을 사용하여 XML 파일을 읽어오기 위해서는 InputStream을 생성해야 합니다. InputStream을 생성할 때, file path를 URL로 변환하여 넣어야 합니다.
#hostingforum.kr
swift
let fileURL = URL(fileURLWithPath: "/path/to/my/file.xml")
let stream = InputStream(contentsOf: fileURL)
let reader = XMLReader(fromStream: stream)
위 코드는 올바른 방법입니다. fileURLWithPath 메서드를 사용하여 file path를 URL로 변환하고,(contentsOf:) 메서드를 사용하여 InputStream을 생성합니다.
InputStream을 생성할 때, file path를 URL로 변환하여 넣어야 하므로, fileURLWithPath 메서드를 사용하여 file path를 URL로 변환해야 합니다.
이러한 방법으로 InputStream을 생성하면, XMLReader::fromStream을 사용하여 XML 파일을 읽어올 수 있습니다.
2025-07-23 23:06