Hunt XML released 1.0.0 rc! Support for parsing, encoding, serialize, unserialize, object binding ..

zoujiaqing zoujiaqing at gmail.com
Thu Dec 5 16:48:01 UTC 2019


>
> Just based on a quick check, it looks like the `validate` 
> method used in your example is just about strictly correct XML 
> -- does the library provide any support for validating messages 
> against a schema?
>
Yes, we will add valid() function to check it.

> And -- mostly out of curiosity -- what are the major 
> differences compared to other D XML libraries such as 
> experimental.xml 
> <https://github.com/dlang-community/experimental.xml> and dxml 
> <https://github.com/jmdavis/dxml> ... ?

Hunt XML: Easier to use API. It's like dom4j..

Have comments like XmlElement, XmlAttribute, XmlIgnore and more ..

## Sample code for it
```D
import hunt.xml;

@XmlRootElement("user")
class User
{

     @XmlAttribute("ID")
     int id = 1001;

     @XmlElement("USERNAME")
     string name;
}

void main()
{
     auto user = new User;

     user.id = 10000;
     user.name = "Brian";

     auto doc = toDocument(user);

     writeln(doc.toPrettyString());
}

```

## Result for sample code
```xml
	<user ID="1002">
		<USERNAME>Brian</USERNAME>
	</user>
```



More information about the Digitalmars-d-announce mailing list