Skip to content

Generating XML attributes and a XML Text node at the same time #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rzacherl opened this issue Mar 20, 2019 · 1 comment
Open

Generating XML attributes and a XML Text node at the same time #9

rzacherl opened this issue Mar 20, 2019 · 1 comment

Comments

@rzacherl
Copy link

Hello,

I have the following class definition with embedded decorators:

@XMLElement({
  root: "ContentFile"
})
export class ContentFile {
  @XMLChild({
    name: ""
  })
  private _path: string;

  @XMLAttribute({
    name: "Numpages"
  })
  private _numPages: number;
...
}

After serialisation I need a XML structure like this:

<ContentFile NumPages="1">this is the value stored in private property _path</ContentFile>

Unfortunately I can't figure out how to do this because as soon as I declare _path as a XMLChild I get a sub-Element:

<ContentFile NumPages="1">
    <_path>this is the value stored in private property _path</_path>
</ContentFile>

I miss something like a @XMLText decorator which allows me to serialize a class property into a XML text node.
Or is it possible to achieve this with existing means?

Best,
Robert

@RobinBuschmann
Copy link
Owner

Hey @rzacherl, thanks for posting this. See this comment: #6 (comment)

Duplicate of #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants