Parsing  unknown  xml  tags

Hi
When the tags are known for xml document
a NodeList could be created and then the Tganame and TagNameValue could be found like so                NodeList nl_t  = elem.getElementsByTagName("type");
               NodeList nl_av = elem.getElementsByTagName("roomsAvailable");
               NodeList nl_pr = elem.getElementsByTagName("price");
                                //  get the element <type> and print 
                             type = (Element)nl_t.item(i);
                              tagname = type.getTagName();
                          node = (Node)nl_t.item(i);
                          nodeName = node.getNodeName();
                              tagnameValue = node.getChildNodes().item(0).getNodeValue() ;
                          // insert item into the vector
                          bb_Vector.add(tagnameValue);
                          System.out.println(  tagname.toString()+"   --->  : " 
                                                    + tagnameValue.toString() +"\n");                   
                             ///    XXXXXXXXXXXXXXX /////
                             //  get the element <price> and print its price
                              price = (Element)nl_pr.item(i);
                              tagname = price.getTagName();
                          node = (Node)nl_pr.item(i);
                          nodeName = node.getNodeName();
                              tagnameValue = node.getChildNodes().item(0).getNodeValue() ;
                          // insert item into the vector
                          bb_Vector.add(tagnameValue);
                          System.out.println(  tagname.toString()+"   --->  : " 
                                                    + tagnameValue.toString() +"\n");                   
  ///  Note the above isjust a  portion of the codeNow I have an xml document and I dont know any of the tags , and I need to scan it and print out all the TagNames and their valuse .
Could someone please help
Thanks
IB

Here's a start:
node = document.getDocumentElement(); //get root node
//traverse document elements beginning from current root node:
            NodeList nodeList = node.getChildNodes();
            int count = nodeList.getLength();
            for (int i = 0; i < count; i++) { //for all children
                Node child = nodeList.item(i);
                if (child != null) { //just to be sure ...
                    String name = child.getNodeName();
                    int type = child.getNodeType();
                    //decoding:
                    switch (type) {
                    case Node.ELEMENT_NODE:
                        Element element = (Element) child;
...

Similar Messages

  • Unknown xml tag extraction

    I have an XML document with the following structure:
    <foo>
         <foo id="F1">television</foo>
         <foo id="F2">car</foo>
    </foo>
    foo id can be none or up to 99. So I want to extract the tag "F1", "F2", etc. and its content when it shows up in a document to enter them in separate fields in a database. I have tried different codes but with no luck. These two are my latest methods but they don't work as expected. The second method gives an error message at the line "matcher = pattern.matcher(xml)". If any one could help I would appreciate it very much.
    _xmlFile is my parsed document. I know it works because I have other methods using getTextContent() with specific tags and work well.
    private void processFoo(Document _xmlFile){
                   String xPath = null;
                   String value = null;
                   xPath = "/*/foo";
                   try{
                        NodeList nodelist = XPathAPI.selectNodeList(_xmlFile, xPath);
                        for(int i2 = 0; i2 < nodelist.getLength(); i2++){
                        Element elem =(Element)nodelist.item(i2);
                        value = elem.toString();
                        value = value.replaceAll("\t", "");
                        value = value.replaceAll("\n", "");
                        value = value.replaceAll("\r", "");
                   }catch(TransformerException transformerexception){
                   addFoo(value);
    public void addFoo(String _xml)
         String regex = null;
         String id = null;
         String content = null;
         Pattern pattern = null;
         Matcher matcher = null;
         String sql = null;
         int index = 0;
         String xml = _xml;
         regex = "\\<foo id=\"F(.+?)\">";
         pattern = Pattern.compile(regex);
         matcher = pattern.matcher(xml);
         while (matcher.find())
                   id = matcher.group(1);
                   id = id.replaceAll("'", "");
                   index = matcher.end(1)+2;
                   index = xml.indexOf("</foo>", index);
                   content = xml.substring(matcher.end(1)+2, index);
                   content = processOfString(content);
                   sql = "INSERT INTO my.Foo (Foo_Id, Foo_Content) VALUES " + "(" + id + ", '" + content + "')";
                   //System.out.println(sql);
                   insertQuery(sql, false);
              xml = xml.substring(index+11, xml.length());
              matcher = pattern.matcher(xml);
    }

    Although I still have a question (which is at the bottom) I finally got what I wanted with the following method.
    private void addFoo(Document _xmlFile){
    String foocontent = null;
    String fooref = null;
    Document doc = _xmlFile;
    String foopath = "foo";
    String sql = null;
    NodeList foo = doc.getElementsByTagName(foopath);
    for (int i = 0; i < foo.getLength(); i++){
    Element foos = (Element) foo.item(i);
    fooref = foos.getAttribute("id");
    foocontent = foos.getTextContent();
    foocontent = foocontent.replaceAll("\t", "");
    footcontent = footcontent.replaceAll("\n", "");
    foocontent = foocontent.replaceAll("\r", "");
    //System.out.println(fooref);
    //System.out.print(foocontent);
    sql = "INSERT INTO insider.footnote SET fooRef = ?, fooText = ?";
    try{
    PreparedStatement addfoo = con.prepareStatement(sql);
    addfoo.setString(1, fooref);
    addfoo.setString(2, foocontent);
    addfoo.executeUpdate();
    }catch(SQLException ex){
    System.err.println("SQLException: " + ex.getMessage());
    my foo table has a primary key that I need as a foreign key in ABC table. So I was wondering if there is anything in java that would allow me to send the key to ABC every time the foo table is updated. Actually, it would better if I can store the key in a variable that I send later with other data that needs to be input into the ABC table.
    Thanks.

  • How can  parse this xml tag " Cell ID="0" Type="String" Afghanistan cell "

    Hi,
    I have to parse this type of xml file.
    so how can i parse this type of xml file like
    <Row ID="1">
    <Cell ID="0" Type="String" >Afghanistan</Cell>
    <Cell ID="1" Type="Number" >93</Cell>
    <Cell ID="2" Type="Number" >0</Cell>
    <Cell ID="3" Type="Number" >1</Cell>
    </Row>

    You haven't given us enough information. Is this for iPhone or Mac OS X? What language are you using? etc.

  • Creating chart leads in XML Parsing Error: mismatched tag. Expected: /svg

    Hello ALL,
    I searched this forum but unfortunately I find not a solution for the following use case:
    described in steps
    1.) create a region with chart (typ = line) -> o.k.
    2.) create a sql statement to have data in the chart -> o.k.
    3.) running report with this created region and chart -> vizualisation o.k.
    3.) create a data picker item ":P21_END_DATE"
    4.) replaced the where clause "WHERE a_timestamp >= To_date ('01.02.2007', 'dd/mm/yyyy HH24:MI') -1/24" with WHERE a_timestamp >= To_date (:P21_END_DATE, 'dd/mm/yyyy HH24:MI') -1/24
    5.) running report with this created region and chart and data picker item -> vizualisation not o.k. I get the attached error message.
    I read already in the forum and knows that the end tag of the svg section is lost put I only changed in my query the described value. Does any body can help me please ??
    king regards
    XML Parsing Error: mismatched tag. Expected: </svg>.
    Location: http://localhost:7777/pls/htmldb/f?p=103:9:8795066316806762442:FLOW_SVG_CHART_R2476324075306576_de
    Line Number 22, Column 1455:</style><script xlink:href="/i/javascript/svg_js_includes/svg_common/oracle.svgInit.js"/><script xlink:href="/i/javascript/svg_js_includes/svg_common/oracle.svgNodes.js"/><script type="text/ecmascript"><![CDATA[function svgSync(){window.reload();}function htmldb_Load(){try{oracleSvgInit(evt);throw "old version" }catch(er){}}]]></script><rect id="background" x="1" y="1" width="1022" height="398"/><text x="20" y="20" class="title">Chart 1</text><text id="XAxisTitle" x="50%" y="390">Minute</text><text id="YAxisTitle" x="15" style="writing-mode:lr;" y="200" transform="rotate(-90,15,200)" text-anchor="middle">Messages</text><g id="legend" transform="translate(0,25)"><rect class="legend" x="1" y="0" width="1022" height="60"/><g class="legenditem" transform="translate(20,18)"><line x1="0" y1="-5" x2="-15" y2="-5" class="data1"/><text class="legend" y="0" x="2">ALL</text></g><g class="legenditem" transform="translate(20,36)"><line x1="0" y1="-5" x2="-15" y2="-5" class="data2"/><text class="legend" y="0" x="2">SMS</text></g><g class="legenditem" transform="translate(20,54)"><line x1="0" y1="-5" x2="-15" y2="-5" class="data3"/><text class="legend" y="0" x="2">LL</text></g></g><svg width="1024" height="400" viewBox="-5 -5 1024 400" preserveAspectRatio="none"> <text class="nodatafound" x="40" y="20">No data found.</text><text class="nodatafound" x="40" y="20">no data found</text><text class="nodatafound" x="40" y="20">no data found</text></g></svg><g id="infobubble" transform="translate(0,0)" style="visibility:hidden"><rect id="infobackground" rx="2" ry="2" x="0" y="0" width="100" height="20" fill-opacity=".9" fill="#FFFFFF" stroke="#000000" stroke-width="1"/><text id="infotext" x="5" y="12">-</text></g><!-- USER FOOTER--></svg>
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^

    I found the solution:
    No data resulting to the query !!

  • Difficulty in parsing the XML root tag through Xpath.

    <?xml version="1.0" encoding="Windows-1252"?>
    <a xsi:schemaLocation="http://www.a.org.uk/ http://www.a.org.uk/schema/2.1/a_general.xsd" CreationDateTime="2013-05-17T08:49:58.7084555+10:00" ModificationDateTime="2011-05-17T08:49:58.7084555+10:00" Modification="new" FileName="a_99-570_-1-sj2.xml" RevisionNumber="3" SchemaVersion="2.1" xml:lang="en" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.a.org.uk/">
         <Localities>
    newyork
    </Localities>
    </a>
    I am not able to parse that xml file due to root tag . Some namespacing issue .Need a solution for that .Do we need to write external class to define all namespacing or some predefined functions can work ?
    Thanks,
    Varun Aggarwal

    But where is the namespace here !?

  • Parse an xml file using cm tag

    I have question about Content Management and weblogic portal 9.2
    In VCR directory, I will have xml file with bellow structure
    Test Repository
    --->Test
    ----Test.xml
    Test.xml File will be like
    <main_content>
         <content>
              <Subject>Subject</Subject>
              <grade><p>This is grade Data</p></grade>
              <mark><p>This is mark Data</p><mark>
    <content>
    <main_content>
    I have used below code to retrieve the above
    <cm:getNode path="/Test Repository/Test/Test.xml" id="headernode" />
    <cm:getProperty id="node" name="_content" />
    Above code will show all the content on Jsp. i,e Subject This is grade Data This is mark Data
    But I only want to retrieve the data of <grade> tag then how can I do this? Please help
    How <cm> tag will help me here ?
    Please provide sample code if have. Your help is highly appreciated.
    Edited by: user11311969 on Sep 10, 2009 2:52 AM
    Edited by: user11311969 on Sep 10, 2009 2:53 AM

    Hi
    Thanks a lot for your swipt reply.
    I try this also But error is same.
    <x:parse var="output" xml="${xml_data}" />
    javax.servlet.ServletException: Unrecognized object supplied as 'xml' attribute to <parse>
    at weblogic.servlet.jsp.PageContextImpl.handlePageException(PageContextImpl.java:409)
    at jsp_servlet._portlets._news.__news._jspService(__news.java:
    <%=xml_data%> returning me a output just as name of file and not content --- > test.xml
    After putting isMultiple="false" i am getting output as ----> test.xml
    resultId defination
    The name of the script variable to store the value of the property in. If this is not specified, the value of the property will be printed in the JSP instead. The value of the property is returned as a collection by default, unless the isMultiple attribute is set to false.
    I think this approch is simple if we can solve this. Is there ant other way same as using tag in jsp itself to retrieve required XML tags. Please reply.. Also i am using Jsp/Html Portlet and not Page Flow Portlet
    Edited by: user11311969 on Sep 11, 2009 1:42 AM
    Edited by: user11311969 on Sep 11, 2009 1:44 AM
    Edited by: user11311969 on Sep 11, 2009 1:44 AM
    Edited by: user11311969 on Sep 11, 2009 1:44 AM

  • Error in parsing taglib 'customtag' tag in web.xml or .tld file of the tagl

    Hi
    While execution Portal application, I am getting error," Error in parsing taglib 'customtag' tag in web.xml or .tld file of the taglib library."
    Complete stack is
    >>#1.5 #005056AE006400690000002000000A440004BA8F3ECB004A#1331024303056#com.sap.portal.prt.runtime#sap.com/irj#com.sap.portal.prt.runtime#M1005000#6994##99593FD6676911E1807500000041A352#99593fd6676911e1807500000041a352-0#99593fd6676911e1807500000041a352#SAPEngine_Application_Thread[impl:3]_31##0#0#Error##Java###02:28_06/03/12_0020_4301650
    [EXCEPTION]
    #1#com.sapportals.portal.prt.servlets_jsp.server.jsp.ParseException: Error in parsing taglib 'customtag' tag in web.xml or .tld file of the taglib library.
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspTaglibDirective.verifyAttributes(JspTaglibDirective.java:189)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspDirective.parse0(JspDirective.java:162)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspDirective.parse(JspDirective.java:117)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.ElementCollection.parse(ElementCollection.java:86)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.ParserImpl.parse(ParserImpl.java:595)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPParser.parse(JSPParser.java:2170)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.compile(JSPCompiler.java:81)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.run(JSPCompiler.java:140)
    at com.sapportals.portal.prt.core.broker.JSPComponentItem.compileJSP(JSPComponentItem.java:291)
    at com.sapportals.portal.prt.core.broker.JSPComponentItem.getComponentInstance(JSPComponentItem.java:141)
    at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.service(PortalComponentItemFacade.java:355)
    at com.sapportals.portal.prt.core.broker.PortalComponentItem.service(PortalComponentItem.java:934)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:435)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:527)
    at com.sapportals.portal.prt.component.AbstractComponentResponse.include(AbstractComponentResponse.java:89)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:232)
    at com.sapportals.portal.htmlb.page.JSPDynPage.doOutput(JSPDynPage.java:76)
    at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:133)
    at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.doPreview(AbstractPortalComponent.java:240)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:168)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
    at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:545)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:434)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1060)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
    at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
    at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
    at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
    at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
    Regards
    Pratyush

    Hi,
    See the following guide and make sure to carefully follow all instructions.
    [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40599e45-8cf9-2910-cbaa-d4cd8e15ff34?QuickLink=index&overridelayout=true&14770392545262]
    Regards,
    Alex

  • Error in parsing taglib taglib tag in web.xml or .tld file of the taglib

    Hi All,
    I have added ResourceBundle.tld file in following path : /PORTAL-INF/taglib/tld/
    I have added portalapp.xml file following entry  :
    <property name="/PORTAL-INF/taglib/tld/ResourceBundle.tld" value="/PORTAL-INF/taglib/tld/ResourceBundle.tld"/>
    I have added jsp file following entry :
    <%@ taglib uri="/PORTAL-INF/taglib/tld/ResourceBundle.tld" prefix="bundle" %>
    I am getting the following the error: Error in parsing taglib taglib tag in web.xml or .tld file of the taglib library
    can you tell me where i am giving the wrong.
    Regards
    Siva

    hi rabih,
    in jsp..
    <%@ taglib uri="tagLib" prefix="bundle" %>
    in portalapp.xml
    <component-profile>
      <property name="tagLib" value="/PORTAL-INF/taglib/tld/ResourceBundle.tld"/>
    </component-profile>
    it may help u..
    regards,
    Chinnadurai.R

  • Unknown PT XML tag 'gatewaylink

    Hi,
    I'm trying to use the gatewayLink tag within my code but it keeps returning 'unknown PT XML tag 'gatewaylink'. I have used the pt:URL tag before so i know that works on the current plumtree portal build we are using (5.04 and edk 2.2) and i have also tested pt:currenttime which also returns a correct value.
    I am using the tags directly in the html code:
    <pt:currentTime xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'/>
    <pt:gatewaylink xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/' pt:fixurl="On" pt:objectID='10' pt:href="portlet.aspx">Click here</pt:gatewaylink>
    but receive this is in the source of the page:
    Apr 11, 2007 9:47:26 AM
    unknown PT XML tag 'gatewaylink Click here unknown PT XML tag 'gatewaylink
    (removed < - - - - > from arround each block of text either side of the click here as they do not show on the forum)
    i am trying to create a link to a specific portlet which will be accessible outside the standard portal interface but still gatewayed.
    can anyone help with this at all?
    Thanks
    Alex
    Edited by cannedfool at 04/11/2007 3:08 AM

    :-( let me just say,
    gatewayLink.

  • Unknown PT XML tag userInfo userinfo

    When using a transformer tag for userinfo in a load balanced environment &#034;one&#034; of the servers returns &#034;<!--unknown PT XML tag 'userInfo-->&#034;. The same code works fine on 3 other servers. What would cause this? I am suspecting it is some configuration on that server, but need to know what to tell our sys admin to look for.
    Thanks for the help. By the way this is in our production environment and I would like to get it resolved before Christmas. :)

    :-( let me just say,
    gatewayLink.

  • Application.xml - Unknown Assembly Tag

    Hello:
    Has anyone encountered the error:
    05/11/18 10:01:39 Error instantiating application at ..... Unknown assembly tag in file:..... <library>
    This happens when I start up the oc4j application server...
    I am positive that it happens because of the following line in my application.xml file:
    <library path="../bvp-web/WEB-INF/lib"/>
    When I take that line out, the applicaiton starts up fine.
    Does anyone have any thoughts as to why I am getting that error? Isn't <library> a tag that is expected to be in the application.xml file?
    I need that line in there since my jsps refer to classes that are in that directory.
    Thanks for your help.

    <library> tag only applies to the orion-application.xml in META-INF/ of a j2ee application or the j2ee/home/config/application.xml, which is actually the orion-application.xml of the default application of oc4j.

  • My application gives "Error in parsing taglib 'tagLib' tag in web.xml "

    Hi ,
    My Portal application developed completely on JSP Dynpages and JSPs gives <b>at times</b> the following error
    "Error in parsing taglib 'tagLib' tag in web.xml or .tld file of the taglib library.."
    I know that this error comes when the taglib declared in the jsp and portalapp.xml doesn't match. But I have made sure that they are the same.
    Can anyone give me an opinion as to why this problem is occuring inspite of making sure that the taglib declaration are same in jsp and portalapp.xml.
    Is the problem on the server side??
    Valuable suggestions would be rewarded!!
    -Thanks
    Padmarajan.

    Hi Anagha,
    No the application is accessed using an http link.
    I am unable to make out why this error comes up only once in a while and when you refresh the screen it starts working fine.
    This is my big issue because when
    -Thanks
    Padmarajan.

  • Creating a PLSQL script to parse structured XML with repeated tags

    Hi, I'm trying to parse an xml feed but the way it's structured makes it difficult to pull out the values. (see example) Would anyone be able to recommend a solution or some ideas as to how to get around this?
    SAMPLE XML:<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
         <env:Header>
         </env:Header>
         <env:Body>
              <ns3:commandResponse xmlns:ns2="http://test.com/2011/Generic/schema" xmlns:ns3="http://test.com/2011/Generic">
                   <return>
                   <ns2:return>success</ns2:return>
                   <ns2:Command>issues</ns2:Command>
                        <ns2:WorkItems>
                             <ns2:Id>216141</ns2:Id>
                             <ns2:ModelType>Issue</ns2:ModelType>
                             <ns2:DisplayId>216141</ns2:DisplayId>
                             <ns2:Field>
                                  <ns2:Name>Type</ns2:Name>
                                  <ns2:Value>
                                       <ns2:Item>
                                            <ns2:Id>Dev Task</ns2:Id>
                                            <ns2:ModelType>Type</ns2:ModelType>
                                            <ns2:DisplayId>Dev Task</ns2:DisplayId>
                                       </ns2:Item>
                                  </ns2:Value>
                             </ns2:Field>
                             <ns2:Field>
                                  <ns2:Name>ID</ns2:Name>
                                  <ns2:Value>
                                       <ns2:int>216141</ns2:int>
                                  </ns2:Value>
                             </ns2:Field>
                             <ns2:Field>
                                  <ns2:Name>Reason</ns2:Name>
                                  <ns2:Value>
                                       <ns2:string>Integrating</ns2:string>
                                  </ns2:Value>
                             </ns2:Field>
                             <ns2:Field>
                                  <ns2:Name>Dev Task Component</ns2:Name>
                                  <ns2:Value>
                                       <ns2:string>Java Tools</ns2:string>
                                  </ns2:Value>
                             </ns2:Field>
                             <ns2:Field>
                                  <ns2:Name>Created Date</ns2:Name>
                                  <ns2:Value>
                                       <ns2:datetime>2009-08-10T15:52:39.000-04:00</ns2:datetime>
                                  </ns2:Value>
                             </ns2:Field>
                             <ns2:Field>
                                  <ns2:Name>Date Closed</ns2:Name>
                                  <ns2:Value/>
                             </ns2:Field>
                             <ns2:Field>
                                  <ns2:Name>Modified Date</ns2:Name>
                                  <ns2:Value>
                                       <ns2:datetime>2011-03-04T12:57:05.000-05:00</ns2:datetime>
                                  </ns2:Value>
                             </ns2:Field>
                        </ns2:WorkItems>
                   </return>
              </ns3:commandResponse>
         </env:Body>
    </env:Envelope>This is just a sample with just one WorkItem, but there would be much more, N number of items with 9 fields per item. (Not all of the fields were put in the sample, and some can have null values)
    I only need to pull the content from /ns2:WorkItems/ns2:Field/ns2:Value/ns2:Item/ns2:Id for the first field and the /ns2:value/* tag of all the other fields. Then put this in a table where each row is a workitem and the fields are the columns (create table workitems (Type,ID,Reason,Dev Task Component,Created Date, Date Closed, Modified Date) --all the fields should be varchar2 except the dates)
    What I've been trying so far seems rather brute force by running a nested loop to go through every item and field and then an IF case for each field 1,2,...9 which would insert the value into a table.
    At the moment I'm using something like below to pull a single value
    path1 = '//ns2:WorkItems[1]/ns2:Field[1]/ns2:Value[1]/ns2:Item[1]/ns2:Id[1]';
    nameserve = 'xmlns:ns2="http://test.com/2011/Generic/schema"';
    extractvalue(xmltype(src_clob),path1,nameserve);I'm not entirely sure if I would be able to substitute the [1]'s with [' || nitem || '] where nitem is loop number to do something like:
    for nitem in 1..itemcount
    loop
        FOR nfield in 1..9
        loop
            if nfield=1 then
                path1 := '//ns2:WorkItems[' || nitem || ']/ns2:Field[' || nfield || ']/ns2:Value[1]/ns2:Item[1]/ns2:Id';
                fieldvalue := extractvalue(xmltype(src_clob),path1,nameserve);';
            else
                path2 := '//ns2:WorkItems[' || nitem || ']/ns2:Field[' || nfield || ']/ns2:Value[1]/*[1]';
                fieldvalue := extractvalue(xmltype(src_clob),path2,nameserve);';
            end if;
        end loop;
    end loop;The problem with the above script is how do I insert this fieldvalue into different columns on a table without using an IF case for each field.
    I was wondering if there is simpler way to put each field into a different column and loop through every workitem. I looked into dynamically naming variables but I don't think plsql supports that.
    Any help/advice is appreciated,
    Thanks!
    Edited by: 843508 on Mar 10, 2011 1:56 PM
    Edited by: 843508 on Mar 10, 2011 1:57 PM
    Edited by: 843508 on Mar 10, 2011 2:01 PM

    If it were me, I wouldn't use PL/SQL to try and process XML, but would use SQL's XMLTABLE functionality e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t as (select XMLTYPE('
      2  <RECSET xmlns:aa="http://www.w3.org">
      3    <aa:REC>
      4      <aa:COUNTRY>1</aa:COUNTRY>
      5      <aa:POINT>1800</aa:POINT>
      6      <aa:USER_INFO>
      7        <aa:USER_ID>1</aa:USER_ID>
      8        <aa:TARGET>28</aa:TARGET>
      9        <aa:STATE>6</aa:STATE>
    10        <aa:TASK>12</aa:TASK>
    11      </aa:USER_INFO>
    12      <aa:USER_INFO>
    13        <aa:USER_ID>5</aa:USER_ID>
    14        <aa:TARGET>19</aa:TARGET>
    15        <aa:STATE>1</aa:STATE>
    16        <aa:TASK>90</aa:TASK>
    17      </aa:USER_INFO>
    18    </aa:REC>
    19    <aa:REC>
    20      <aa:COUNTRY>2</aa:COUNTRY>
    21      <aa:POINT>2400</aa:POINT>
    22      <aa:USER_INFO>
    23        <aa:USER_ID>3</aa:USER_ID>
    24        <aa:TARGET>14</aa:TARGET>
    25        <aa:STATE>7</aa:STATE>
    26        <aa:TASK>5</aa:TASK>
    27      </aa:USER_INFO>
    28    </aa:REC>
    29  </RECSET>') as xml from dual)
    30  -- END OF TEST DATA
    31  select x.country, x.point, y.user_id, y.target, y.state, y.task
    32  from t
    33      ,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
    34                '/RECSET/aa:REC'
    35                PASSING t.xml
    36                COLUMNS country NUMBER PATH '/aa:REC/aa:COUNTRY'
    37                       ,point   NUMBER PATH '/aa:REC/aa:POINT'
    38                       ,user_info XMLTYPE PATH '/aa:REC/*'
    39               ) x
    40      ,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
    41                '/aa:USER_INFO'
    42                PASSING x.user_info
    43                COLUMNS user_id NUMBER PATH '/aa:USER_INFO/aa:USER_ID'
    44                       ,target  NUMBER PATH '/aa:USER_INFO/aa:TARGET'
    45                       ,state   NUMBER PATH '/aa:USER_INFO/aa:STATE'
    46                       ,task    NUMBER PATH '/aa:USER_INFO/aa:TASK'
    47*              ) y
    SQL> /
       COUNTRY      POINT    USER_ID     TARGET      STATE       TASK
             1       1800          1         28          6         12
             1       1800          5         19          1         90
             2       2400          3         14          7          5p.s. XML questions are better suited in the XML DB forum:
    XML DB FAQ

  • Getting characters in a particular xml tag type during Sax parsing.

    How do I get the text within a certain XML tag using the parser. I can use the parser which will get me all the text in all the tags, but how do I get the ones I need only.
    For example:
    <channel id="south-east.bbc1.bbc.co.uk">
        <display-name lang="en">BBC1</display-name>
        <display-name>1</display-name>
      </channel>
      <programme start="20040217233500" stop="20040218000500 +0000" channel="south-east.bbc1.bbc.co.uk">
        <title lang="en">Film 2004 with Jonathan Ross</title>
      </programme>how do I get the text 'Film 2004 with Jonathan Ross' without getting the others?

    Well, the SAX parser just gives you the start/end tag
    information to a handler, right? So if you just use
    the SAX parser to get one item, then you could do it
    by running thru the entire XML file to get that item
    then get another item. Clearly this isn't the best
    way to do it.... The handler should put the data for
    the whole document into some data structure, or use
    DocumentBuilder to get a Document object. I see. Yes, that is not the way to use SAX. It's kind of an inside out way of doing things. If you using SAX you should know everything that you want before parsing and grab all of them in one fell swoop.
    If you want to get an in memory representation, the JDOM package is a whole lot eaiser to use than DOM.

  • XML Parsing Error: mismatched tag. Expected: /img .

    Hi All,
    I need help to solve a problem, I created a data model consist of multiple tables, the query is working fine with parameters.
    My question is, i created a parameter called JOB and checked the Multiple selection. when i run, it throw the below error
    XML Parsing Error: mismatched tag. Expected: </img>.
    Location: http://admin.abc.com:9704/xmlpserver/servlet/xdo
    Line Number 2, Column 580
    :<table style='background=color: #d9e5ef; margin-top: 10px;' width='100%' cellspacing='0' cellpadding='0' border='0' summary=''><tbody><tr><td class='error_dialog_header-start'></td><td class='error_dialog_header'></td><td class='error_dialog_header-end'></td></tr><tr><td class='error_dialog_content-start'></td><td class='error_dialog_content'><div><div style='margin: 4px 0 2px;'><span><img height='18px' border='0' alt='' src='/xmlpserver/cabo/images/swan/errorl.gif'/></span><span><img src='/xmlpserver/resource/blafplus/generic/spacer.gif' width='5px' height='1px' alt=''></span><span class='errorMessage'>Error</span></div><div style='margin: 4px 0 2px;' class='statusText'>The data model cannot be executed because of an error, please contact the administrator.</div><div style='margin: 8px 10px 2px;' class='statusText'><a class='dataLink' href='#' onclick="javascript:document.getElementById('errordetail').style.display='block';return false;">Error Detail</a></div></div></td><td class='error_dialog_content-end'></td></tr><tr><td class='error_dialog_footer-start'></td><td class='error_dialog_footer'></td><td class='error_dialog_footer-end'></td></tr></tbody></table><div class='errorMessage' id='errordetail' style='display: none; margin-top: 10px;'>oracle.xdo.XDOException: oracle.xdo.XDOException: oracle.xdo.XDOException: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
    can any one help me to solve the problem.
    Thanks  

    Hi,
    What was your image path or URL?
    Have you tried to find the source without the tag?
    Upload the XML file to review it.
    Regards,
    Liviu

Maybe you are looking for

  • TAX LINE ITEMS

    Hi Experts, This is Suma Mani ,my client having retail stores in India and back support is SAP ECC6.0.My business wants cummulative tax figures would requires post with sales docuemetns not line item wise. Evey busines transaction should be one tax l

  • [SOLVED] AssaultCube not connecting to server

    I guess the title says it all . I think there might be a update soon , according to this  ..... http://forum.cubers.net/thread-1181.html       Please let me know if you have the same problem , Thanks Last edited by sliposk (2010-10-15 14:45:46)

  • How to change direction of menuitems in Menubarcontrol ? help me out plz.....

    Hi all,         i am working with menubar control , how to change the menu items direction ? thanks -Satish

  • Using first call? in LVOOP

    LVOOP experts, I am quite green when in comes to LV classes, but am striving to understand them better. Is there any way to use the First Call? primitive inside a static dispatch method VI? It seems to work fine when I have one instance of my class,

  • Coloring row problem of JTable

    Hi! I'm the beginer and have a problem while coloring rows in my table. The problem is as follows: i need to color the whole row when i click a single cell of this row. Everything is ok until i click another cell of another row. When i do it all the