Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74996

Re: Removing xml element and strip extra space

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <varun292006@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'that?': 0.05; 'removes': 0.07; '&lt;?xml': 0.09; '22,': 0.09; 'subject:extra': 0.09; 'subject:xml': 0.09; 'trailing': 0.09; 'cc:addr:python-list': 0.11; 'suggest': 0.14; 'added.': 0.16; 'carriage': 0.16; 'newlines': 0.16; 'preserving': 0.16; 'removed:': 0.16; 'scrape': 0.16; 'skip:n 50': 0.16; 'suggestion.': 0.16; 'tim,': 0.16; 'whitespace.': 0.16; 'for?': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'written': 0.21; '8bit%:5': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'skip:e 30': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'tim': 0.29; 'xml': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'work.': 0.31; 'getting': 0.31; 'file:': 0.31; 'strip': 0.31; 'way?': 0.31; 'anyone': 0.31; 'file': 0.32; 'there.': 0.32; 'handled': 0.32; 'url:python': 0.33; 'skip:& 30': 0.33; 'actual': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'skip:& 10': 0.38; 'thank': 0.38; 'pm,': 0.38; 'does': 0.39; 'itself': 0.39; 'space': 0.40; 'url:mail': 0.40; 'remove': 0.60; 'blank': 0.60; 'removing': 0.60; 'skip:n 30': 0.60; 'skip:\xc2 10': 0.60; 'mentioned': 0.61; 'skip:* 10': 0.61; "you're": 0.61; 'july': 0.63; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'default': 0.69; 'construction': 0.72; 'jul': 0.74; '\xc2\xa0\xc2\xa0': 0.74; 'skip:n 40': 0.81; '3:00': 0.84; 'br,': 0.84; 'monte': 0.84; 'returns.': 0.84; 'subject:space': 0.84; 'xslt': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=XC7cNmsnN2VfjLefVZtEv5sthkIwvzM/3dqkj8bowo4=; b=Fqo1USlB6K3+LVw8KmXvmAxp98t19DunbqaQFctJR99/j84fg4tNHuvFnnKPOWxAN3 KQPNDSfq6fdGu0QiJtlGepGT19AaiTwHryCmuYNO9gBdD2aEhbZWnDKIFMedLY0pjT3G E/FwMFT8Q1PePGfbwAcgqVDq6dEebASIYv/Cz/b7t/oO8LgUpwuF9WtEzciFOuzmMTCj 4IiTnwkwrCV3ijkmy9OWsK+1skEgBjlAmSx8NARjLSbcQ+D14qgEZm77BJrPi7/X/uMx uaJVDFeyBSesZVpt4FH6tJ45Z/dp09DmEaOX31kuMBeOq1yVGFnZe+2IAuEJD59nThjc eg4w==
MIME-Version 1.0
X-Received by 10.236.141.80 with SMTP id f56mr4715693yhj.149.1406036560863; Tue, 22 Jul 2014 06:42:40 -0700 (PDT)
In-Reply-To <7597f8b7-2989-44f2-804b-c3dc5c0e6154@googlegroups.com>
References <CAGxOggEanm=FmXLgcP4tRuwSzvURANeNtShZbFxeGKMSSXZAmA@mail.gmail.com> <slrnlsslu3.a0j.memilanuk@machin-shin.milanuk.lan> <mailman.12180.1406033623.18130.python-list@python.org> <7597f8b7-2989-44f2-804b-c3dc5c0e6154@googlegroups.com>
Date Tue, 22 Jul 2014 15:42:40 +0200
Subject Re: Removing xml element and strip extra space
From varun bhatnagar <varun292006@gmail.com>
To Tim <jtim.arnold@gmail.com>
Content-Type multipart/alternative; boundary=20cf303635bbc0668d04fec865c8
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12181.1406036570.18130.python-list@python.org> (permalink)
Lines 197
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406036570 news.xs4all.nl 2889 [2001:888:2000:d::a6]:44485
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74996

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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@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...@invalid.com>
> wrote:
> > On 2014-07-22, varun bhatnagar <varun...@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
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Removing xml element and strip extra space varun bhatnagar <varun292006@gmail.com> - 2014-07-22 14:53 +0200
  Re: Removing xml element and strip extra space Tim <jtim.arnold@gmail.com> - 2014-07-22 06:00 -0700
    Re: Removing xml element and strip extra space varun bhatnagar <varun292006@gmail.com> - 2014-07-22 15:42 +0200
    Re: Removing xml element and strip extra space Monte Milanuk <memilanuk@invalid.com> - 2014-07-22 17:39 +0000

csiph-web