Skip to content
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

Partially preserving XML? #19

Open
Sam-Costigan opened this issue Dec 2, 2015 · 2 comments
Open

Partially preserving XML? #19

Sam-Costigan opened this issue Dec 2, 2015 · 2 comments
Labels
Milestone

Comments

@Sam-Costigan
Copy link

Hi Chris,

Awesome work, I just had a quick question! I'm currently looking at using this module for pulling in data from multiple XML documents with the same data in different formats and it looks like exactly what I need. There's just one issue, given the following snippet:

<titles>
    <title>Orbital anisotropy and low-energy excitations of the
                quasi-one-dimensional conductor
        <math display="inline">
            <mi>β</mi></math>-Sr
        <math display="inline">
            <msub>
                <mrow/>
                <mrow>
                    <mn>0.17</mn></mrow>
            </msub>
        </math>V
        <math display="inline">
            <msub>
                <mrow/>
                <mn>2</mn></msub>
        </math>O<title></title>
        <math display="inline">
            <msub>
                <mrow/>
                <mn>5</mn></msub>
        </math>
    </title>
</titles>

I want to get everything within the title tags, including the various math tags and their children. This doesn't seem to be possible currently. Either I can access title.cdata and get the stripped down string, or I can loop through the title.math list. Is this something you can see happening in the future?

Thanks,
Sam

@stchris
Copy link
Owner

stchris commented Dec 2, 2015

Hi Sam,

thank you for your comments. As to your problem, I'm afraid it is quite specific and I currently can't think of a way of implementing it without drastically changing the code and the API. I'd like to keep this ticket open and think about it some more, though. If you have any more thoughts on this, feel free to add them here.

Cheers,
Chris

@stchris stchris added this to the 2.0.0 milestone Mar 9, 2017
@FarzanRNobakht
Copy link

I have the same problem
Can't we simply add a tostring method to Element Class which iterates over attributes and children of the element and returns back the xml string corresponding to the element?

(although it may not print the attributes of the element in the same other as original xml)

just like
https://docs.python.org/2/library/xml.etree.elementtree.html#xml.etree.ElementTree.tostring

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

No branches or pull requests

3 participants