Replacing harcoded XML element attributes with variables

Is there any way for Xpath expressions in JAVA to refer to variables (for an attribute) instead of harcoded strings (like 'abc' and 'xyz' below)
So below ... 'abc' , 'xyz' could be varaibles.....
String getServerInstance="/Accounts/Account[@code='abc']/TestingProgram[@code='abc']/Modes/Mode[@code='xyz']/*";
Thanks a lot

I have a class now that resolves variables:
public class Resolve_Xpath_Vars implements XPathVariableResolver
     public Object resolveVariable(QName var)
try {          
          if (var.equals(new QName("pqr")))
                    return new String("pqr");
          else if (var.equals(new QName("abcde")))
                    return new String("abcde");
else
return null;
catch (Exception ex)
          ex.printStackTrace();
          throw new RuntimeException();     
NOWWWWW
how do i configure my XPATH expression to call this class to reolve my varaible....
XPATH EXPRESSION IS:
"this.Account" is the variable that the class should resolve.....to "pqr"
String getAccnt="/Accounts/Account[@code="+"'"+*this.Account*+"'"+"]/*";      
Once resolved to "pqr" then i can make the following call:
NodeList nodeList =(NodeList) xPath.evaluate(getAccnt, inputSource, XPathConstants.NODESET );
any help is appreciated.............

Similar Messages

  • [CS5-5.5][JS] Replace xml element content with user selection

    Hi,
    I'm trying to write a script that replaces xml element content with a user selection.
    I have document containing a textframe with a "root" tag attached. In this frame I have 2 paragraphs, each tagged with a different tag.
    I would like to replace the content of one of the paragraphs with the content of a text selection.
    This piece of code doesn't seem to work:
    myXMLElement.xmlContent = app.selection[0];
    The problem is that almost all properties of the xmlelement (paragraphs, words, etc) are read-only.
    Does anyone have any suggestion?
    Thanx

    It depends on whether you want to maintain formatting. You can use
    myXMLElement.contents = app.selection[0].contents;
    in the (unlikely?) event that you don't mind blowing away the formatting. Otherwise you'll want to use something like:
    myXMLElement.xmlContent.remove();
    app.selection[0].duplicate(LocationOptions.AT_BEGINNING, myXMLElement.xmlContent);
    Jeff

  • Need to replace/modify an element attribute

    Hi,
    I need to read an XML file and modify the value of an XML element attribute and write the modified element back to the file. This element is two levels deep in the heirarchy,
    currently i am reading all the children and modifying the value of this particular attribue and writing all the children back.
    Does anybody know of a method where we can do a replace operation on the Document rather than the lengthy process that i am currrently using??
    Thanks

    you might want to look at STX streaming transforms-
    http://www.xml.com/pub/a/2003/02/26/stx.html
    That seems a good match for a simple replace problem.
    Pete

  • Pixel-Positions in XML-Element attributes

    hi,
    is there a way, when attaching a xml-tag to e.g. a picture, that the top and left pixel value is saved in a xml-element attribute? the pixel value from top and from the left.
    thanks in advance.
    regards.

    hi,
    is there a way, when attaching a xml-tag to e.g. a picture, that the top and left pixel value is saved in a xml-element attribute? the pixel value from top and from the left.
    thanks in advance.
    regards.

  • XML element "userComments" of variable "UserComments" is not defined error while deploying AccountDistribution composite to soa server

    Hi,
    We did deploying AccountDistribution composite to soa server hosted in our test environment but We could not succeed as the following error was thrown on compilation itself in Jdeveloper.
    <snip>
         Error(124): XML element "{http://xmlns.oracle.com/InvoiceSynchronization/AccountDistribution/AccountDistribution}userComments" of variable "UserComments" is not defined
    <snip>
    We have had 4 variables defined with element attribute in our AccountDistribution bpel
    <variable name="UserComments" element="client:userComments"/>
    and for every variable we are coming up with this error on composite deployment.
    We have tried multiple workarounds like deleting SCA-INF of AccountDistribution that is auto generated by Jdeveloper etc but but no luck, we are still coming up with same error.
    We back traced for the element's definition i.e userComments definition and we could find the definition in xsd stored in MDS as per configuration.
    Please provide your advise on how to proceed further on this issue.
    Thanks,
    Satheesh

    Hi Nicolas,
    adf-config.xml is for all the composites present in the project, but we are getting this error in only 1 composite, our other composites are working fine without any error.
    We tried creating a new variable with type element and getting same error.
    Thanks
    Satheesh

  • JS: how can find role in XML element attribute

    Dear All,
    We could gather "footnote" XML elements as an array. But we need to filter the elements which has "role=endnote" in the attributes from the group of common footnote tagged elements .
    Eg. <footnote xml:id="en2" label="2" role="endnote"> from myGetXMLElements("//footnote")
    Kindly assist to get footnote XML elements which has the role "endnote".
    regards
    Masthan

    Hi Fred,
    Yes, I got it. Thanks
    regards
    Masthan

  • Replace User msRTCSIP-GroupingID attribute with the OU ObjectGUID

    Hello!
    I am trying to create a script that will replace the users msRTCSIP-GroupingID attribute with the OU ObjectGUID
    Can anyone help with this
    Get-ADUser -Filter * -SearchBase "OU=Test,OU=Tenants,DC=Mayernetworks,DC=COM"
    $OUobjectGUID = get-ADOrganizationalUnit -filter * -searchbase "ou=test,ou=tenants,dc=mayernetworks,dc=com" | ft ObjectGUID
    Set-ADUser $Accounts -Add @{"msRTCSIP-GroupingID"=$OUobjectGUID}
    i'm getting the argument is null error
    bradley Wyatt

    I dont think this is supported 
    The attribute msRTCSIP-GroupingID should
    not be used in a commercial hosting environment and is not supported by Microsoft due
    to the privacy and security risks when providing multi-tenancy in a hosting environment. The use of the attribute only simulates a grouping of users in logical partitions, and does not create a true partition in which the security and privacy of the tenants
    can be tightly controlled.
    Please remember, if you see a post that helped you please click ;Vote As Helpful" and if it answered your question please click "Mark As Answer" Regards Edwin Anthony Joseph

  • XML Parsing attributes with encoded ampersand causes wrong order

    Hi all,
    I am writing in the forum first (because it could be that i am doing something wrong.... but i think it is a bug. Nonetheless, i thought i'd write my problem up here first.
    I am using Java 6, and this has been reproduced on both windows and linux.
    java version "1.6.0_03"
    Problem:
    read XML file into org.w3c.dom.Document.
    XML File has some attributes which contain ampersand. These are escaped as (i think) is prescribed by the rule of XML. For example:
    <?xml version="1.0" encoding="UTF-8"?>
         <lang>
              <text dna="8233" ro="chisturi de plex coroid (&gt;=1.5 mm)" it="Cisti del plesso corioideo(&gt;=1.5mm)" tr="Koro&#305;d pleksus kisti (&gt;=1.5 mm)" pt_br="Cisto do plexo cor&oacute;ide (&gt;=1,5 mm)" de="Choroidplexus Zyste (&gt;=1,5 mm)" el="&Kappa;&#973;&sigma;&tau;&epsilon;&iota;&sigmaf; &chi;&omicron;&rho;&omicron;&epsilon;&iota;&delta;&omicron;&#973;&sigmaf; &pi;&lambda;&#941;&gamma;&mu;&alpha;&tau;&omicron;&sigmaf; (&gt;= 1.5 mm)" zh_cn="&#33033;&#32476;&#33180;&#22218;&#32959;&#65288;&gt;= 1.5 mm&#65289;" pt="Quisto do plexo coroideu (&gt;=1,5 mm)" bg="&#1050;&#1080;&#1089;&#1090;&#1072; &#1085;&#1072; &#1093;&#1086;&#1088;&#1080;&#1086;&#1080;&#1076;&#1085;&#1080;&#1103; &#1087;&#1083;&#1077;&#1082;&#1089;&#1091;&#1089; (&gt;= 1.5 mm)" fr="Kystes du plexus choroide (&gt;= 1,5 mm)" en="Choroid plexus cysts (&gt;=1.5 mm)" ru="&#1082;&#1080;&#1089;&#1090;&#1099; &#1089;&#1086;&#1089;&#1091;&#1076;&#1080;&#1089;&#1090;&#1099;&#1093; &#1089;&#1087;&#1083;&#1077;&#1090;&#1077;&#1085;&#1080;&#1081; (&gt;=1.5 mm)" es="Quiste del plexo coroideo (&gt;=1.5 mm)" ja="&#33032;&#32097;&#33180;&#22178;&#32990;&#65288;&gt;=1.5mm&#65289;" nl="Plexus choroidus cyste (&gt;= 1,5 mm)" />
    </lang>As you might understand, we need to have the fixed text '>' for later processing. (not the greater than symbol '>' but the escaped version of it).
    Therefore, I escape the ampersand (encode?) and leave the rest of the text as is. And so my > becomes >
    All ok?
    Symptom:
    in fetching attributes, for example by the getAttribute("en") type call, the wrong attribute values are fetched.
    Not only that, if i only read to Document instance, and write back to file, the attributes are shown mixed up.
    eg:
    dna: 8233, ro=chisturi de plex coroid (>=1.5 mm), en=&#1082;&#1080;&#1089;&#1090;&#1099; &#1089;&#1086;&#1089;&#1091;&#1076;&#1080;&#1089;&#1090;&#1099;&#1093; &#1089;&#1087;&#1083;&#1077;&#1090;&#1077;&#1085;&#1080;&#1081; (>=1, de=Choroidplexus Zyste (>=1,5 mm)Here you can see that 'en' is shown holding what looks like greek, ... (what is ru as a country-code anyway?) where it should have obviously had the english text that originally was associated with the attribute 'en'
    This seems very strange and unexpected to me. I would have thought that in escaping (encoding) the ampersand, i have fulfilled all requirements of me, and that should be that.
    There is also no error that seems to occur.... we simply get the wrong order when fetching attributes.
    Am I doing something wrong? Or is this a bug that should be submitted?
    Kind Regards, and thanks to all responders/readers.
    Sean
    p.s. previously I had not been escaping the ampersand. This meant that I lost my ampersand in fetching attributes, AND the attribute order was ALSO WRONG!
    In fact, the wrong order was what led me to read about how to correctly encode ampersand at all. I had been hoping that correctly encoding would fix the order problem, but it didn't.
    Edited by: svaens on Mar 31, 2008 6:21 AM

    Hi kdgregory ,
    Firstly, sorry if there has been a misunderstanding on my part. If i did not reply to the question you raised, I appologise.
    In this 'reply' I hope not to risk further misunderstanding, and have simply given the most basic example which will cause the problem I am talking about, as well as short instructions on what XML to remove to make the problem disappear.
    Secondly, as this page seems to be displayed in ISO 8859-1, this is the reason the xml I have posted looks garbled. The xml is UTF-8. I have provided a link to the example xml file for the sample below
    [example xml file UTF-8|http://sean.freeshell.org/java/less2.xml]
    As for your most recent questions:
    Is it specified as an entity? To my knowledge (so far as my understanding of what an entity is) , yes, I am including entities in my xml. In my below example, the entities are the code for the greater than symbol. I am under the understanding that this is allowed in XML ??
    Is it an actual literal character (0xA0)? No, I am specifying 'greater than' entity (code?) in order to include the actual symbol in the end result. I am encoding it in form 'ampersand', 'g character', 't character', 'colon' in order for it to work, according to information I have read on various web pages. A quick google search will show you where I got such information from, example website: https://studio.tellme.com/general/xmlprimer.html
    Here is my sample program. It is longer than the one you kindly provided only because it prints out all attributes of the element it looks for. To use it, only change the name of the file it loads.
    I have given the xml code seperately so it can be easily copied and saved to file.
    Results you can expect from running this small test example?
    1. a mixed up list of attributes where attribute node name no longer matches its assigned attribute values (not for all attributes, but some).
    2. removing the attribute bg from the 'text' element will reduce most of these symptoms, but not all. Removing another attribute from the element will most likely make the end result look normal again.
    3. No exception is thrown by the presence of non xml characters.
    IMPORTANT!!! I have only just (unfortunately) noticed what this page does to my unicode characters... all the the international characters get turned into funny codes when previewed and viewed on this page.
    Whereas the only codes I am explicitly including in this XML is the greater than symbol. The rest were international characters.
    Perhaps that is the problem?
    Perhaps there is an international characters problem?
    I am quite sure that these characters are all UTF-8 because when I open up this xml file in firefox, It displays correctly, and in checking the character encoding, firefox reports UTF-8.
    In order to provide an un-garbled xml file, I will provide it at this link:
    link to xml file: [http://sean.freeshell.org/java/less2.xml]
    Again, sorry for any hassle and/or delay with my reply, or poor reply. I did not mean to waste anyones time.
    It will be appreciated however if an answer can be found for this problem. Chiefly,
    1. Is this a bug?
    2. Is the XML correct? (if not, then all those websites i've been reading are giving false information? )
    Kindest Regards,
    Sean
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    public class Example
        public static void main(String[] argv)
              try
                   FileInputStream fis = new FileInputStream("/home/sean/Desktop/chris/less2.xml");
                 Document doc = DocumentBuilderFactory.newInstance()
                 .newDocumentBuilder()
                 .parse(new InputSource(fis));
                   Element root = doc.getDocumentElement();
                   NodeList textnodes = root.getElementsByTagName("text");
                   int len = textnodes.getLength();
                   int index = 0;
                   int attindex = 0;
                   int attrlen = 0;
                   NamedNodeMap attrs = null;
                   while (index<len)
                        Element te = (Element)textnodes.item(index);
                        attrs = te.getAttributes();
                        attrlen = attrs.getLength();
                        attindex = 0;
                        Node node = null;
                        while (attindex<attrlen)
                             node = attrs.item(attindex);          
                             System.out.println("attr: "+node.getNodeName()+ " is shown holding value: " + node.getNodeValue());
                             attindex++;                         
                        index++;
                        System.out.println("-------------");
                 fis.close();
              catch(Exception e)
                   System.out.println("we've had an exception, type "+ e);
    }  [example xml file|http://sean.freeshell.org/java/less2.xml]
    FOR THE XML, Please see link above, as it is UTF-8, and this page is not. Edited by: svaens on Apr 7, 2008 7:03 AM
    Edited by: svaens on Apr 7, 2008 7:23 AM
    Edited by: svaens on Apr 7, 2008 7:37 AM
    Edited by: svaens on Apr 7, 2008 7:41 AM

  • XML element attributes in program

    I am using following FMs to create XML document from internal table
    CALL FUNCTION 'SDIXML_DATA_TO_DOM'
    CALL FUNCTION 'SDIXML_DOM_TO_XML'
    My internal table has field 'AMT' and generated XML file has following line
    <AMT>1000</AMT>
    But I want this line to be generated as <AMT Ccy = 'USD'>1000</AMT>
    I tried to use set_attribute method of element but not able to get this.I should be missing somethig as I am new to this XML.
    Can anyone please advsie how I can get this?
    Thanks for your help.
    Srinivas

    Hello Srinivas
    Below you see sample coding that I use on SAP-PI to map attributes into the XML stream (INVOIC IDoc)::
    NOTE: mo_document is of TYPE REF TO if_ixml_document (which is exported as DATA_AS_DOM by fm SDIXML_DATA_TO_DOM).
    METHOD MAP_SD_DOC_CAT_AND_BILL_TYPE.
    * define local data
      DATA: ld_billingdoc         TYPE bapivbrkout-billingdoc,
            ld_billing_type       type bapivbrkout-bill_type,
            ld_sd_doc_category    TYPE vbtyp,
            ld_edi_qualifier      TYPE string.
      " Location code mapping only for outbound invoices, i.e.
      " invoices sent by subsidiary to its customers
      CHECK ( is_outbound_invoic( ) = abap_true ).
      CALL METHOD zcl_edi_idoc_invoic_services=>get_billingdoc_detail
        EXPORTING
          param              = mif_param
    *      id_idocnumber      =
          id_rfc_destination = md_rfcdest
        IMPORTING
          ed_billingdoc      = ld_billingdoc
          ed_billing_type    = ld_billing_type
          ed_sd_doc_category = ld_sd_doc_category
          ed_edi_qualifier   = ld_edi_qualifier.
    * NOTE: We add the SD document category and the EDI qualifier
    *       as attributes to E1EDK01/BELNR.
    **  <E1EDK01 SEGMENT="1">
    **      <CURCY>EUR</CURCY>
    **      <HWAER>EUR</HWAER>
    **      <WKURS>1.00000</WKURS>
    **      <ZTERM>T60F</ZTERM>
    **      <EIGENUINR>nnn</EIGENUINR>
    **      <BSART>INVO</BSART>
    **      <BELNR SD_DOC_CATEGORY="O" EDI_QUALIFIER="381" BILL_TYPE="ZOII">
    **        1010010911
    **      </BELNR>
    **      <NTGEW>97.662</NTGEW>
    **      <BRGEW>127.239</BRGEW>
    **      <GEWEI>KGM</GEWEI>
    **      <FKART_RL>LR</FKART_RL>
    **      <RECIPNT_NO>0000823305</RECIPNT_NO>
    **      <FKTYP>L</FKTYP>
    **  </E1EDK01>
      DATA: ld_name       TYPE string,
            ld_value      TYPE string,
            ld_rc         TYPE i,
            lo_node       TYPE REF TO if_ixml_node,
            lo_node_child TYPE REF TO if_ixml_node,
            lo_clone      TYPE REF TO if_ixml_node,
            lo_children   TYPE REF TO if_ixml_node_list,
            lo_element    TYPE REF TO if_ixml_element,
            lo_attribute  TYPE REF TO if_ixml_attribute,
            lo_filter     TYPE REF TO if_ixml_node_filter,
            lo_iter       TYPE REF TO if_ixml_node_iterator,
            lo_doc        TYPE REF TO if_ixml_document.
    * Filter for nodes of segment E1EDK01
      lo_filter = mo_document->create_filter_name( name = 'E1EDK01' ).
      CALL METHOD mo_document->create_iterator_filtered
        EXPORTING
    *      depth  = 0
          filter = lo_filter
        RECEIVING
          rval   = lo_iter.
      DO.
        lo_node = lo_iter->get_next( ).
        EXIT.
      ENDDO.
    * NODE: First (and single) parent node is the entire E1EDK01 segment
      lo_children = lo_node->get_children( ).
      lo_filter = mo_document->create_filter_name( name = 'BELNR' ).
      lo_iter = lo_children->create_iterator_filtered( lo_filter ).
    * NOTE: We should have a single child node => BELNR
      DO.
        lo_node = lo_iter->get_next( ).
        EXIT.
      ENDDO.
      CHECK ( lo_node IS BOUND ).
      ld_name  = lo_node->get_name( ).
      ld_value = lo_node->get_value( ).
      LOG-POINT ID zedi
                      SUBKEY mc_subkey_runtime
                      FIELDS syst-index ld_name ld_value.
    * Add attribute SD_DOC_CATEGORY and EDI_QUALIFIER to element BELNR
      lo_element ?= lo_node.
      ld_name  = 'SD_DOC_CATEGORY'.
      ld_value = ld_sd_doc_category.
      CALL METHOD lo_element->set_attribute
        EXPORTING
          name  = ld_name
          value = ld_value
        RECEIVING
          rval  = ld_rc.
      ld_name  = 'EDI_QUALIFIER'.
      ld_value = ld_edi_qualifier.
      CALL METHOD lo_element->set_attribute
        EXPORTING
          name  = ld_name
          value = ld_value
        RECEIVING
          rval  = ld_rc.
      ld_name  = 'BILL_TYPE'.
      ld_value = ld_billing_type.
      CALL METHOD lo_element->set_attribute
        EXPORTING
          name  = ld_name
          value = ld_value
        RECEIVING
          rval  = ld_rc.
    ENDMETHOD.
    Regards
      Uwe

  • XML Gateway Mapping of XML Element Attribute

    Hi:
    If an inbound XML message contains this tag:
    <STATUS CODE="100"></STATUS>
    is it possible to map the CODE attribute to a database column?
    I've been attempting to do this but I'm receiving this error: Element STATUS not complete, expected elements ''.
    Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I'll answer my own question here.  Found the section in the XML User Guide about mapping HTTP Error Responses (chapter 22 in the v6.1 pdf) and realized that the XML gateway had preconfigured settings to handle various error conditions.  Edited the error handling configuration for the specific Handler (rather than the global setting) and checked the box to allow the error to pass through the XML gateway.  Redeployed the subpolicy.

  • Reading XML element attribute

    I use JSTL to read a remote XML but can only print the content of the elements. How do i print the content of the attributes?
    <root><person id="1">George</person></root>
    For example, to read the Person's name i use:
    <x:out select="$xmloutput/ROOT/person"/>
    But how do i print the ID value of the element?
    Thanks in advance.

    Already found the answer:
    <x:out select="@attribute_name" />
    Just add the @ sign

  • Parse XML Elements/Attributes from CLOB into Oracle Table

    Hi!
    I have an XML file (loaded into a CLOB) which I need to parse and have each individual element and attribute inserted into an oracle table for manipulation.
    Eg: XML File...
    <PERSON>
    <PER_ID changed="1">1</PER_ID>
    <SURNAME changed="1">MARTIN</SURNAME>
    <ADDRESS>
    <STREET_NO changed="1">1</STREET_NO>
    <POSTCODE changed="1">LE3 8RA</POSTCODE>
    </ADDRESS>
    </PERSON>
    There will only ever be one address.
    From this I need to extract
    * PER_ID and related changed attribute
    * SURNAME and related changed attribute
    * STREET_NO and related changed attribute
    * POSTCODE and related changed attribute
    and insert a single record into the table below:
    CREATE TABLE PERSON AS
    ( PER_ID VARCHAR2(10)
    , ID_CHANGED VARCHAR2(1)
    , SURNAME VARCHAR2(30)
    , ID_CHANGED VARCHAR2(1)
    , STREET_NO VARCHAR2(5)
    , ID_CHANGED VARCHAR2(1)
    , POSTCODE VARCHAR2(10) );
    Any assistance/advice would be very much appreciated. I've tried using DBMS_XMLSave / DBMS_XMLStore which works great at pulling in elements (PER_ID, SURNAME, etc) straight into the table but doesn't look at the changed attributes, and I need both.
    Thanks a million in advance to anyone who can crack this!!
    Jay

    Try looking at this thread
    Loading datafrom a PL/SQL table into the Database table

  • Storing Element attributes with Oracle XSU

    I'm trying to take an XML feed and store it into and oracle table. I can get all the elements and sub-elements, but all the attributes end up being NULL. Is there anyway I can get the XML SQL Utility to load my attributes?
    Thanks.

    Can some one help please?

  • Get element attributes with JDOM

    Dear JDOM experts,
    I am learning JDOM.
    Here is a piece of codes:
    SAXBuilder saxBuilder = new SAXBuilder();
    doc = saxBuilder.build(new File(filename));
    Element rootElement=doc.getRootElement();
    System.out.println ("rootElement.getName() = "+ rootElement.getName());
    List attributeList=rootElement.getAttributes();
    System.out.println ("attributeList.size()= "+ attributeList.size());
    Iterator attributeIterator=attributeList.iterator();
    while (attributeIterator.hasNext()) {
    Attribute attribute=(Attribute)attributeIterator.next();
    System.out.println ("attribute.getName()= "+ attribute.getName());
    System.out.println ("attribute.getValue()= "+ attribute.getValue());
    I applied it to
    <NODE SHORTNAME="008O1-C2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="F:\mydeltaxml\Pegase.xsd">
    The root element has three attributes.
    But why did I get only two as
    rootElement.getName() = NODE
    attributeList.size()= 2
    attribute.getName()= SHORTNAME
    attribute.getValue()= 008O1-C2
    attribute.getName()= noNamespaceSchemaLocation
    attribute.getValue()= F:\mydeltaxml\Pegase.xsd
    Any explanation?
    Regards,
    AG

    Hi, JDOM expert,
    Thanks for the reply.
    However, I still have a small doubt.
    Please notice that in
    <NODE SHORTNAME="008O1-C2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="F:\mydeltaxml\Pegase.xsd">
    For "xsi:noNamespaceSchemaLocation="F:\mydeltaxml\Pegase.xsd", why was the prefix xsi not taken by the parser as a part of the attribute name?
    Best regards,
    AG

  • Parse XML Elements/Attributes from CLOB in PL/SQL

    Hi folks,
    I'm new to XML development in Oracle...I need some help in Parsing a XML stored in a CLOB column using PL/SQL.
    We are using Oracle 9i R2. Do i need install the XDK and /or XML DB?
    Basically the xml has some quiz questions and the answers to the quiz. Once student submits the quiz we need parse the XML and calculate the grade.
    Any help is appreciated...
    Thanks,

    A bit dirty but this works:
    Create an XMLType based on the CLOB contents...
    select extractvalue(value(x), '/PERSON/PER_ID/text()') PER_ID, extractvalue(value(x), '/PERSON/PER_ID/@changed') PER_ID_CHG
    , extractvalue(value(x), '/PERSON/SURNAME/text()') PER_SURNAME, extractvalue(value(x), '/PERSON/SURNAME/@changed') PER_SURNAME_CHG
    , extractvalue(value(x), '/PERSON/ADDRESS/STREET_NO/text()') PER_STREET_NO, extractvalue(value(x), '/PERSON/ADDRESS/STREET_NO/@changed') PER_STREET_NO_CHG
    , extractvalue(value(x), '/PERSON/ADDRESS/POSTCODE/text()') PER_POSTCODE, extractvalue(value(x), '/PERSON/ADDRESS/POSTCODE/@changed') PER_POSTCODE_CHG
    from table(xmlsequence(extract(xmltype('
    <PERSON>
    <PER_ID changed="1">260180</PER_ID>
    <SURNAME changed="2">MARTIN</SURNAME>
    <ADDRESS>
    <STREET_NO changed="3">1</STREET_NO>
    <POSTCODE changed="4">LE3 8RA</POSTCODE>
    </ADDRESS>
    </PERSON>')
    , 'PERSON')
    ) x;

Maybe you are looking for

  • Only one top level element is allowed in an XML document. Line 2, Position 2

    I get this error when I try to run an xsql query with a where clause: Only one top level element is allowed in an XML document. Line 2, Position 2 <font size='-1' face='monospace'>XSQL-005: XSQL page is not well-formed.</font><BR> -^ Here is the xsql

  • Refresh of BW development from BW production - consequences

    One of the customers I work with - we are looking at refreshing BW Development system from BW production - just to bring them in sync . I believe this can cause issues with 1) object ownership - the TADIR entry for all objects - "originating system"

  • How to Load Progressive-Download Video just when I press Play?

    I have set the Progressive-Download video instead of Streaming-Video (because my webserver provider "aruba.it" doesn't offer streaming videos), in Flash CS4 Professional, and exported to Dreamweaver CS4. I have also inserted the HTML code in Dreamwea

  • Error 150

    I get the error message: "150: failed sending data to the peer" when I try to upload a largish photo in GoLive. It is uploading html files just fine. Dreamweaver uploads large .jpgs, which made me think the problem is Golive but But right now Faceboo

  • Why does the form flicker?

    Using fillable/saveable forms saved from http://www.cra-arc.gc.ca/formspubs/t1gnrl/on-eng.html and then opened in Adobe Reader X. Several forms are open. All documents are maximized. A variety of scales (page fit, width fit, other) were used. All of