Skip to content

Experimental: add dom wrapper #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed

Experimental: add dom wrapper #56

wants to merge 9 commits into from

Conversation

tafia
Copy link
Owner

@tafia tafia commented Mar 7, 2017

This PR adds a very basic DOM like wrapper on top of quick-xml pull based reader.

The typical usage is:

use quick_xml::dom::Node;

let file = File::open(...);
let root_node = Node::root(file).expect("error while converting xml into DOM node");
let special_nodes = root_node.select_all("child1/child2/child3");
for n in special_nodes {
    println!("attributes: {}", n.attributes());
}
for n in root_node.children_mut() {
    *n.name_mut() = "My new Name".to_string();
}

@blanham
Copy link

blanham commented May 23, 2017

Do you plan on merging this anytime soon?

@tafia
Copy link
Owner Author

tafia commented May 24, 2017

I don't know. I do not really need it at the moment and I haven't been asked it. It was more a proof of concept.
Would you be interested?

@melroy89
Copy link
Contributor

I'm interested, but wouldn' it be better to create a separate crate for this (probably also the reason you don't merge it into quick-xml now)? Thus also a separate git repo in this same project.

@tafia
Copy link
Owner Author

tafia commented Jun 22, 2017

Yes it would definitely be better on another crate. Eventually I'd love having a crate just to declare the traits to have a DOM and several implementation (including one for quick-xml, xml-rs, xml5ever, RustyXML etc ...).

I am still struggling to find some time but if anyone wants to starts I'll be happy to help!

@melroy89
Copy link
Contributor

I try to use your dom, after some hacking (like escape module is private), I now get stuck at:

error[E0382]: use of moved value: start
--> src/parse/dom.rs:340:41
|
339 | start.with_attributes(self.attributes.iter().map(|&(ref k, ref v)| (&**k, &**v)));
| ----- value moved here
340 | writer.write_event(Event::Start(start))?;
| ^^^^^ value used here after move
|
= note: move occurs because start has type quick_xml::events::BytesStart<'_>, which does not implement the Copy trait

error: aborting due to previous error

@tafia
Copy link
Owner Author

tafia commented Jun 26, 2017

Sorry I haven't answered that!
This dom is really very experimental for the moment. There are definitely some pain points to fix.
For instance, reading at the error, I am not sure the writer needs to move the value. A borrow should be enough.

@tafia
Copy link
Owner Author

tafia commented Jul 5, 2017

I am closing this for now as minidom crate has apparently switched to using quick-xml.

Let me know if you think otherwise.

@tafia tafia closed this Jul 5, 2017
tafia added a commit that referenced this pull request Jul 6, 2017
This pull request strictly improves the current situation (shouldn't be a breaking change).  

Fixes situation like #56 (comment)
@tafia tafia deleted the dom branch March 21, 2018 05:32
@ColinKinloch
Copy link

I updated this code to work with the current quick-xml here.
I don't intend to continue working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants