Skip to content
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

How do you parse a subelement? #220

Open
NickMcG opened this issue Feb 8, 2022 · 1 comment
Open

How do you parse a subelement? #220

NickMcG opened this issue Feb 8, 2022 · 1 comment
Labels

Comments

@NickMcG
Copy link

NickMcG commented Feb 8, 2022

I have some EDI that I'd like to parse that looks like this:

REF*WS*CHBOH*0*QO>358>AD>20220608~

In other words, 358, AD, and 20220608 are all subelements of the REF04 element. Is there a way for me to get at the data?

I currently have REF defined as this:

        [EdiSegment, EdiPath("REF")]
        public class REF
        {
            [EdiValue(Path = "REF/0")]
            public string ReferenceIdentificationQualifier { get; set; }

            [EdiValue(Path = "REF/1")]
            public string ReferenceIdentification { get; set; }

            [EdiValue(Path = "REF/2")]
            public string Description { get; set; }

            [EdiValue(Path = "REF/3")]
            public string RefIdentifier { get; set; }
        }

When I parse and print out the data, I can see REF*WS*CHBOH*0*QO, but I can't get to the >358>AD>20220608.

Is there a way to get it to either drop the subelements into a property, or just eagerly grab everything? I'm perfectly fine parsing it after the majority of the EDI has been handled.

@cleftheris
Copy link
Contributor

cleftheris commented Feb 21, 2022

Hi @NickMcG,

you could make use of an additional structural class for elements and make use of the attribute [EdiElement]. Elements contain subelements (components) that are the values so in your example above REF/4 should be mapped to a class that has 4 components as properties.

check this model here that contains an example of Element and Segment use in the same file (The example transmission file).

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

No branches or pull requests

2 participants