Skip to content

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

Description

@rzacherl

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions