hamcrest/JavaHamcrest — pull request #64 by EarthCitizen (2014-09-19 12:24:12+00:00)
Title: Added xml() method to allow converting various sources of XML into Node

Allows arbitrary sources of XML to be be compatible with the `HasXPath` matcher by converting to `Node`. Currently handles `File`, `String` and `InputStream` conversions. For any class it does not recognize, it will call `toString()`.

Unit tests complete for multiple scenarios.

##### Examples

```Java
/* Converts File to Node */
File file = new File("file.xml");
assertThat(file, xml(hasXPath("/elementOne/elementTwo"));
```

```Java
/* Converts String to Node */
String xmlString = "Text";
assertThat(xmlString, xml(hasXPath("/elementOne/elementTwo"));
```

```Java
/* As a last resort will call toString() on anything it does not recognize */
StringBuffer buffer = new StringBuffer();
buffer.append("");
buffer.append("Text");
buffer.append("");

assertThat(buffer, xml(hasXPath("/elementOne/elementTwo"));
```

##### Additional Improvements / TODO
* JavaDoc (I can take care of that this weekend, currently very late here)
* Some discussion on how best to handle exceptions related to parsing the XML
* Potential minor refactoring for reduction of repeat code
* Allow `Node` instances to pass through as-is
* Add more detailed messages for mismatches potentially different for each source type