Thread overview
Hunt XML released 1.0.0 rc! Support for parsing, encoding, serialize, unserialize, object binding ..
Dec 05, 2019
zoujiaqing
Dec 05, 2019
Adam D. Ruppe
Dec 06, 2019
Adam D. Ruppe
Dec 05, 2019
zoujiaqing
Dec 05, 2019
JN
December 05, 2019
# Hunt-XML
A XML library for D Programming Language. Support for parsing, encoding, serialize, unserialize, object binding!

## Features
* DOM parser: parse XML Document
* DOM writer: to string and to file
* Object serialization/deserialization


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

void main()
{
    Document doc = Document.parse("<single-element attr1='one' attr2=\"two\"/>");

    if(doc.validate())
    {
        auto node = doc.firstNode();

        writeln(node.getName()); // print single-element
    }
}
```

### Sample code for File load / save
```D
import hunt.xml;

void main()
{
	Document document = Document.load("resources/books.xml");

	document.save("output.xml");
}
```

Source code repository:
https://github.com/huntlabs/hunt-xml

DLang package:
https://code.dlang.org/packages/hunt-xml


December 05, 2019
On Thursday, 5 December 2019 at 15:55:29 UTC, zoujiaqing wrote:
> # Hunt-XML
> A XML library for D Programming Language. Support for parsing, encoding, serialize, unserialize, object binding!
>
> ## Features
> * DOM parser: parse XML Document
> * DOM writer: to string and to file
> * Object serialization/deserialization

Cool, congratulations :-)

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?

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> ... ?
December 05, 2019
On Thursday, 5 December 2019 at 16:14:01 UTC, Joseph Rushton Wakeling wrote:
> And -- mostly out of curiosity -- what are the major differences compared to other D XML libraries

or my beloved dom.d
December 05, 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>
```

December 05, 2019
On Thursday, 5 December 2019 at 16:48:01 UTC, zoujiaqing wrote:
> ## Sample code for it
> ```D
> import hunt.xml;
>
> @XmlRootElement("user")
> class User
> {
>
>     @XmlAttribute("ID")
>     int id = 1001;
>
>     @XmlElement("USERNAME")
>     string name;
> }

I like the declarative API, can't wait to give it a go. Reminds me of JAXB :)
December 06, 2019
On Thursday, 5 December 2019 at 16:28:48 UTC, Adam D. Ruppe wrote:
> On Thursday, 5 December 2019 at 16:14:01 UTC, Joseph Rushton Wakeling wrote:
>> And -- mostly out of curiosity -- what are the major differences compared to other D XML libraries
>
> or my beloved dom.d

Indeed!  Sorry for missing it out.  I've found it friendly and helpful for a number of use-cases, but as they were all related to HTML parsing, my mental map of dom.d is a bit focused on that, and its broader uses skipped my mind.
December 06, 2019
On Friday, 6 December 2019 at 08:58:38 UTC, Joseph Rushton Wakeling wrote:
> as they were all related to HTML parsing

Indeed, it is biased toward that use case, but it actually does quite a few extra things too that I don't market as much (and takes some extra code to fully enable - like the embedded <% code %> support - but still).