---
title: "init(contentsOf:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/xmlparser/init(contentsof:)"
---

# init(contentsOf:)

Initializes a parser with the XML content referenced by the given URL.

## Declaration

```swift
convenience init?(contentsOf url: URL)
```

## Parameters

- `url`: An doc://com.apple.foundation/documentation/Foundation/NSURL object specifying a URL. The URL must be fully qualified and refer to a scheme that is supported by the NSURL class.

## Return Value

Return Value An initialized NSXMLParser object or nil if an error occurs.

## See Also

### Related Documentation

- [Event-Driven XML Programming Guide](apple-archive/documentation/Cocoa/Conceptual/XMLParsing.md)

### Initializing a Parser Object

- [init(data:)](foundation/xmlparser/init(data:).md)
- [init(stream:)](foundation/xmlparser/init(stream:).md)
