Here is one way using the XML package:

> x <- '<?xml version="1.0" encoding="utf-8"?>
+ <as:Job xmlns:as="urn:tibco:spotfire.dxp.automation">
+   <as:Tasks>
+     <OpenAnalysisFromLibrary
+ xmlns="urn:tibco:spotfire.dxp.automation.tasks">
+       <as:Title>Open Analysis from Library</as:Title>
+       <AnalysisPath>/Z- Archive - TO BE
+ purged/ConditionEmailTest</AnalysisPath>
+     </OpenAnalysisFromLibrary>
+     <SendEmail xmlns="urn:tibco:spotfire.dxp.automation.tasks">
+       <as:Title>Send Email</as:Title>
+       <Recipients>
+         <string>chidambaramselvaku...@gmail.com</string>
+ <string>chidambaramselvaku...@gmail.com</string>
+       </Recipients>
+       <Subject>Sales Report</Subject>
+       <Message>Hi,
+
+ Good Day!
+
+ Thanks for achieving your sales target.
+
+ Regards,
+ Chidambaram</Message>
+       <Links />
+       <Attachments />
+     </SendEmail>
+   </as:Tasks>
+ </as:Job>'
> require(XML)
>
> doc <- xmlParse(x)
> docRoot <- xmlRoot(doc)
>



> # change the second email and then output
> docRoot[["Tasks"]][["SendEmail"]][["Recipients"]][[2]][['text']] <- "
n...@domain.tv"
> print(docRoot)



<as:Job xmlns:as="urn:tibco:spotfire.dxp.automation">
  <as:Tasks>
    <OpenAnalysisFromLibrary
xmlns="urn:tibco:spotfire.dxp.automation.tasks">
      <as:Title>Open Analysis from Library</as:Title>
      <AnalysisPath>/Z- Archive - TO BE
purged/ConditionEmailTest</AnalysisPath>
    </OpenAnalysisFromLibrary>
    <SendEmail xmlns="urn:tibco:spotfire.dxp.automation.tasks">
      <as:Title>Send Email</as:Title>
      <Recipients>
        <string>chidambaramselvaku...@gmail.com</string>
        <string>n...@domain.tv</string>
      </Recipients>
      <Subject>Sales Report</Subject>
      <Message>Hi,

Good Day!

Thanks for achieving your sales target.

Regards,
Chidambaram</Message>
      <Links/>
      <Attachments/>
    </SendEmail>
  </as:Tasks>
</as:Job>



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Fri, Nov 14, 2014 at 12:34 PM, Chidambaram Selvakumar <
chidambaramselvaku...@gmail.com> wrote:

> Hi Team,
>
> Can you please help me on the below?
>
> 1) Is it possible to achieve the below requirement through or not?
>        Open XMl; find and remove the all the string tag;add new string tag
> based on the email count; save it in the same XML.
> 2) If yes can you please share the script
>
> As I am new to R script, I am expecting your help to achieve this.
>
> Thanks in advance.
>
> Regards
> Chidambaram
> On Nov 8, 2014 1:10 PM, "Chidambaram Selvakumar" <
> chidambaramselvaku...@gmail.com> wrote:
> >
> > Hi Team,
> >
> > I have the below xml file where i have to find and remove all the email
> address in <string> tag and need to append the new email address using R
> script.May be string tag needs to be added or decreased based on the email
> list.
> >
> > XM File
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <as:Job xmlns:as="urn:tibco:spotfire.dxp.automation">
> >   <as:Tasks>
> >     <OpenAnalysisFromLibrary
> xmlns="urn:tibco:spotfire.dxp.automation.tasks">
> >       <as:Title>Open Analysis from Library</as:Title>
> >       <AnalysisPath>/Z- Archive - TO BE
> purged/ConditionEmailTest</AnalysisPath>
> >     </OpenAnalysisFromLibrary>
> >     <SendEmail xmlns="urn:tibco:spotfire.dxp.automation.tasks">
> >       <as:Title>Send Email</as:Title>
> >       <Recipients>
> >         <string>chidambaramselvaku...@gmail.com</string>
> > <string>chidambaramselvaku...@gmail.com</string>
> >       </Recipients>
> >       <Subject>Sales Report</Subject>
> >       <Message>Hi,
> >
> > Good Day!
> >
> > Thanks for achieving your sales target.
> >
> > Regards,
> > Chidambaram</Message>
> >       <Links />
> >       <Attachments />
> >     </SendEmail>
> >   </as:Tasks>
> > </as:Job>
> >
> > Kindly help me. It is little urgent.
> >
> > Thanks in advance for your effort and support.
> >
> > Regards,
> > Chidambaram
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to