Click here to Skip to main content
15,888,259 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an Angular client app with a form.

HTML
<form class="example-form">
        <mat-form-field class="example-full-width" appearance="fill">
            <mat-label>SMTP Host</mat-label>
            <textarea matInput placeholder="Ex: smtp.gmail.com"></textarea>
        </mat-form-field> <br>
        <mat-form-field class="example-full-width" appearance="fill">
            <mat-label>SMTP Port</mat-label>
            <textarea matInput placeholder="Ex: 587"></textarea>
        </mat-form-field> <br>
        <mat-form-field class="example-full-width" appearance="fill">
            <mat-label>SMTP User Name</mat-label>
            <textarea matInput placeholder="Ex: example@gmail.com"></textarea>
        </mat-form-field> <br>
        <mat-form-field class="example-full-width" appearance="fill">
            <mat-label>SMTP User Password</mat-label>
            <textarea matInput placeholder="Ex: password"></textarea>
        </mat-form-field> <br>
        <mat-form-field class="example-full-width" appearance="fill">
            <mat-label>SMTP From</mat-label>
            <textarea matInput placeholder="Ex: example@gmail.com"></textarea>
        </mat-form-field> <br>
        <mat-form-field class="example-full-width" appearance="fill">
            <mat-label>SMTP Display Name</mat-label>
            <textarea matInput placeholder="Ex: Jhon"></textarea>
        </mat-form-field> <br>
        <mat-form-field class="example-full-width" appearance="fill">
            <button mat-button>Save</button>
        </mat-form-field>
    </form>


What I want to do is to save the content of each form's field in a XML file which will be read by other app. How could I accomplish this task? I have seen that file-saver could be something that might be helping me, but I'm not sure how.

I'm working with:

Angular CLI: 12.2.5

Node: 14.17.6

Package Manager: npm 6.14.15

Package Version
@angular-devkit/architect 0.1202.5 (cli-only)

@angular-devkit/core 12.2.5 (cli-only)

@angular-devkit/schematics 12.2.5 (cli-only)

@schematics/angular 12.2.5 (cli-only)

What I have tried:

File-saver
Posted
Updated 5-May-22 1:28am

1 solution

Try using JavaScript [^] and XML packages Angular-XML [^]. Hope it helps.
 
Share this answer
 
Comments
DrgIonuţ 24-May-22 7:35am    
Sorry for being so late with a reply! I don't want to convert XML to JSON. I want to generate the XML when the Save button is clicked. So far I managed to generate the XML file but its content is not correct. How could I generate the XML with a proper content?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900