Removing xml element and strip extra space

varun bhatnagar varun292006 at gmail.com
Tue Jul 22 09:42:40 EDT 2014


Hi Tim,

Thanks for replying.
No that is not the output I am looking for.

I just want to scrape out <nodeBase base="0" />
But the way I have written my xsl file it is removing it but it is also
leaving a blank space there. I want my output to look like this:




*<?xml version="1.0" encoding="UTF-8"?><testNode><nodeInfo><nodePeriod
nodeTime="600000000"/>*

*</nodeInfo></testNode>*

But in actual it is showing like this:

<?xml version="1.0" encoding="UTF-8"?>
<testNode>
<nodeInfo>
<nodePeriod nodeTime="600000000"/>
                                <---------------------------- *I want to
remove this space* :)
</nodeInfo>
</testNode>



On Tue, Jul 22, 2014 at 3:00 PM, Tim <jtim.arnold at gmail.com> wrote:

> On Tuesday, July 22, 2014 8:53:35 AM UTC-4, varun bhatnagar wrote:
> > Hi,
> > Thank you so much for the suggestion.
> > I tried using the rstrip() function but that did not work. Still getting
> a blank space between <nodePeriod> and </nodeInfo> as mentioned in the
> above output xml file:
> > <nodePeriod nodeTime="600000000"/>
> >  </nodeInfo>
> > Is there any other way through which this can be achieved? Can't this be
> handled by xslt itself in some way?
> >
> > Thanks,
> >
> > BR,
> > Varun
> > On Tue, Jul 22, 2014 at 2:23 PM, Monte Milanuk <memi... at invalid.com>
> wrote:
> > On 2014-07-22, varun bhatnagar <varun... at gmail.com> wrote:
> > > I want to strip the space between *<nodePeriod>* and *</nodeInfo>*
> > > Can anyone suggest a way out to do that?
> > Look at str.rstrip() - by default it removes trailing whitespace
> > including carriage returns.
> > --
>
> Hi Varun,
> The whitespace is part of your original xml; the xslt is only preserving
> that whitespace. Do you have any control over the construction of that
> original xml?
>
> It looks like it has been tidied and whitespace perhaps added. I think you
> will get what you want if the original has the newlines removed:
> <?xml version="1.0" encoding="UTF-8"?>
> <testNode>
> <nodeInfo>
> <nodePeriod nodeTime="600000000"/><nodeBase base="0" /></nodeInfo>
> </testNode>
>
> does that get you what you're looking for? Is the whitespace actually
> necessary in the original or problematic in the result?
>
> --Tim Arnold
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140722/2b904b92/attachment.html>


More information about the Python-list mailing list