ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Using XML-INTO with this XML Fragment

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using XML-INTO with this XML Fragment

    How do I set a data structure to handle this XML Fragment?

    D xmlFragment S 256A VARYING

    D RespError DS
    D Type 1A
    D ShortText 17A
    D Error 34A

    xmlFragment = '<Error Type="1" ShortText="Unable to process" Code="450">Item is invalid. - NonRoomItemID (or NonRoomBundleID) is not valid.</Error>';
    xml-into RespError %XML(xmlFragment);

    Thanks.
    '

  • #2
    Dcl-ds Error Qualified;
    type char(1);
    shortText char(17);
    text char(34);
    End-ds;

    Add the option datasubf=text to the XML-INTO and that's it.

    Comment


    • #3
      Wouldn't you also need a subfield for Code (unless you specified Allow Missing = Yes)?

      Dcl-ds Error Qualified;
      type char(1);
      shortText char(17);
      code char(3);
      text char(34);
      End-ds;

      Comment


      • #4
        Yes Brian - you would. I just included the fields the OP had in his D-specs.

        Comment


        • #5
          Except you should say "allowextra=yes" if you didn't have a Code subfield.

          Comment


          • #6
            Right, that's what I meant to say (you believe me, don't you?)

            Comment

            Working...
            X