Skip to content
New issue

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

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

Already on GitHub? # to your account

Order of val in relation to children? #37

Closed
orchlon opened this issue Jul 7, 2016 · 3 comments
Closed

Order of val in relation to children? #37

orchlon opened this issue Jul 7, 2016 · 3 comments

Comments

@orchlon
Copy link

orchlon commented Jul 7, 2016

I don't know if this is an issue because I'm not 100% familiar with XML specifications, but I don't seem to be able to know where the val is in relation to the children, for example for this xml string

    <some>
        <child> first child val </child>
        some val
        <child>second child val</child>
     </some>

seems to give no indication where some val is, and if the string is like this

    <some>
        <child>first child val</child>
        some val
        <child>second child val</child>
        some more val
     </some>

some val is completely ignored in favor of some more val.

@nfarina
Copy link
Owner

nfarina commented Jul 7, 2016

So you are correct, this is valid XML. But xmldoc doesn't support this kind of "mixed content" in favor of the simplicity of the val property. Otherwise you'd have to write node.children[0].val where the child is a text node, instead of the more intuitive node.val. Are you parsing HTML or XML?

@orchlon
Copy link
Author

orchlon commented Jul 8, 2016

I'm parsing XML from an open document format file. To be clear I haven't actually run into mixed content, but I don't know if I will get mixed content too, though I think it's unlikely. What I'm more worried about is the first case where I don't know if some val comes after the first child.

@nfarina
Copy link
Owner

nfarina commented Jul 8, 2016

Yeah, that information will unfortunately be lost by xmldoc. You could probably make some simple modifications to the library to retain the text nodes as additional children, or you might investigate a more full-featured library like node-elementtree.

I hope this answers your original question - closing this issue for now!

@nfarina nfarina closed this as completed Jul 8, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants