1 Reply Latest reply: Sep 28, 2012 12:02 PM by Jason_(A_Non) RSS

    Read or check the value of xml element having namespace

    869022
      Hi All,

      Where am I wrong ? can anybody help me please.

      EXISTSNODE(columnname,'//ErrorList/Error/@datatypes:ErrorType',
      'xmlns:datatypes="http://company.com/schemas/cal/datatypes" xmlns:tns="http://company.com/schemas/canonical/cal/error"
      xmlns:calheader="http://company.com/schemas/canonical/cal/header" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') = 1

      Is is possible to check the value of the Node <datatypes:*ErrorType*> without using the namespace.



      <?xml version = '1.0' encoding = 'UTF-8'?><tns:ErrorMessage xsi:schemaLocation="http://company.com/schemas/canonical/cal/Error.xsd"
      xmlns:datatypes="http://company.com/schemas/cal/datatypes" xmlns:tns="http://company.com/schemas/canonical/cal/error"
      xmlns:calheader="http://company.com/schemas/canonical/cal/header" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <tns:CALHeader>
      <calheader:VersionNumber>String</calheader:VersionNumber>
      </tns:CALHeader>
      <tns:ErrorList>
      <datatypes:Error>
      <datatypes:ErrorDescription>String</datatypes:ErrorDescription>
      <datatypes:*ErrorType*>DATA_ERROR</datatypes:ErrorType>
      </datatypes:Error>
      </tns:ErrorList>
      </tns:ErrorMessage>

      Thanks,
      Krishna

      Edited by: 866019 on 28-Sep-2012 08:07
        • 1. Re: Read or check the value of xml element having namespace
          Jason_(A_Non)
          What version of Oracle?
          select * from v$version;

          Based on what you provided, you are looking for something like
          EXISTSNODE(columnname,'//tns:ErrorList/datatypes:Error/datatypes:ErrorType',
          'xmlns:datatypes="http://company.com/schemas/cal/datatypes" xmlns:tns="http://company.com/schemas/canonical/cal/error"') = 1
          You only are required to include namespace declarations for any namespace used in the XPath. Avoid the use of // where possible so if you can, include tns:ErrorMessage in the XPath.
          Is is possible to check the value of the Node <datatypes:*ErrorType*> without using the namespace.
          A. If you remove all the namespaces from the XML {message:id=10506398}. As Odie says, it can be done but is it worth the effort.
          B. Maybe via XQuery but I don't dabble enough to know how to pull that off (assuming it is possible).