Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74994 > unrolled thread
| Started by | varun bhatnagar <varun292006@gmail.com> |
|---|---|
| First post | 2014-07-22 14:53 +0200 |
| Last post | 2014-07-22 17:39 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | varun bhatnagar <varun292006@gmail.com> |
|---|---|
| Date | 2014-07-22 14:53 +0200 |
| Subject | Re: Removing xml element and strip extra space |
| Message-ID | <mailman.12180.1406033623.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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 <memilanuk@invalid.com> wrote: > On 2014-07-22, varun bhatnagar <varun292006@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. > > -- > https://mail.python.org/mailman/listinfo/python-list >
[toc] | [next] | [standalone]
| From | Tim <jtim.arnold@gmail.com> |
|---|---|
| Date | 2014-07-22 06:00 -0700 |
| Message-ID | <7597f8b7-2989-44f2-804b-c3dc5c0e6154@googlegroups.com> |
| In reply to | #74994 |
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
[toc] | [prev] | [next] | [standalone]
| From | varun bhatnagar <varun292006@gmail.com> |
|---|---|
| Date | 2014-07-22 15:42 +0200 |
| Message-ID | <mailman.12181.1406036570.18130.python-list@python.org> |
| In reply to | #74995 |
[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
>
[toc] | [prev] | [next] | [standalone]
| From | Monte Milanuk <memilanuk@invalid.com> |
|---|---|
| Date | 2014-07-22 17:39 +0000 |
| Message-ID | <mailman.12188.1406050809.18130.python-list@python.org> |
| In reply to | #74995 |
On 2014-07-22, varun bhatnagar <varun292006@gmail.com> wrote: > 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: This is the part where a certain amount of example code showing what you're doing would probably help people diagnose where the problem is...
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web