Reading XML items results in error

Leon67Leon67 Member Posts: 5
Hi All,

I am currently trying to read a xml document. So far all works fine besides the tags that are optional.

If a optional tag is not present in the xml document a error occurs. I want to test if a optional tag is present or not before reading it but I can't seem to find a way to do this, can anyone point me in the right direction?

Regards,

Leon

Comments

  • jhoekjhoek Member Posts: 216
    I suppose the answer depends on which technique you are using. Are you using the XMLDOM? Show us some code, and someone may be able to help you! :)
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • GoMaDGoMaD Member Posts: 313
    If you are using xmlPorts check the following:

    If your tag is an attribute, check the property Occurrence and set it to Optional
    if your tag is an element , check the properties MinOccurs and MaxOccurs:
    set MinOccurs to Zero and MaxOccurs to Unbounded

    If you are using XMLDOM check the Commerce Portal Codeunit 6226 "XML Document Decode"

    An excerpt of this Codeunit where the existence of the tag GUID is done:
      IF NOT FindNode(XMLNode,'GUID',XMLNodeFound) THEN
        EXIT
      ELSE
        IF STRLEN(XMLNodeFound.text) > 0 THEN
          GUID := XMLNodeFound.text;
    

    Hope this helps!
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • Leon67Leon67 Member Posts: 5
    I am using XMLDom objects, not xml ports. I'll look into the codeunit this may be the answer I was looking for.

    Regards,

    Leon
Sign In or Register to comment.