XML parsing with SQL/PL-SQL

Hi,
My question is about how can an XML message can be best parsed using SQL/PL-SQL.
The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.
In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.
Apologies for this basic question but I have never done XML parsing in SQL/PL-SQL before.
Thank you.
PS I have copied this question to the XML forum.
Edited by: user3112983 on May 19, 2010 3:30 PM
Edited by: user3112983 on May 19, 2010 3:39 PM

user3112983 wrote:
The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.Parsing is done using the XMLTYPE data type (object class) in Oracle.
Something as follows:
SQL> create table xml_doc( id number, doc clob );
Table created.
SQL>
SQL> insert into xml_doc values( 1, '<root><row><name>John</name></row><row><name>Jack</name></row></root>' );
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> declare
  2          rawXml  xml_doc.doc%type;
  3          xml     xmltype;
  4  begin
  5          -- get the raw XML (as a CLOB)
  6          select doc into rawXml from xml_doc where id = 1;
  7
  8          -- parse it
  9          xml := new xmltype( rawXml );  
10         -- process the XML...
11  end;
12  /
PL/SQL procedure successfully completed.
SQL>The variable xml in the sample code is the XML DOM object. XML functions can be used against it (e.g. to extract values in a tabular row and column structure).
Note that the CLOB needs to contain a valid XML. An XML containing XML fragments is not valid and cannot be parsed. E.g.
SQL> declare
  2          xml     xmltype;
  3  begin
  4          -- attemp to parse fragments
  5          xml := new xmltype( '<row><name>John</name></row>  <data><column>Name</column></data>' );
  6  end;
  7  /
declare
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00245: extra data after end of document
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 301
ORA-06512: at line 5This XML contains 2 fragments. A row structure and a data structure. It is not a valid XML and as such cannot be parsed. If a root tag is used to encapsulate these 2 fragments, then it will be a valid XML structure.
In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.Have not run into any XML performance problems specifically - and am using it extensively. Even large XMLs (10's of 1000's of elements) parse pretty fast.

Similar Messages

  • XML Parsing error in PL/SQL

    Hello,
    I have some problem in parsing Mircrosoft OpenXML file using Oracle 10g Release2 XML Parser for PL/SQL.
    I use dbms_xmlparser, dbms_xmldom, dbms_xslprocessor packages
    OpenXML file use "w:" as namespace, so every element has prefix "w:" like
    <w:wordDocument ..>
    <w:body..>
    <w:p..>
    <w:r..>
    <w:t..>
    My job is to read OpenXML file inside PL/SQL code, parse it, and load it into the corresponding table.
    Here is my PL/SQL code.
    DECLARE
    doc dbms_xmldom.DOMDocument;
    node_list dbms_xmldom.DOMNodeList;
    l_node dbms_xmldom.DOMNode;
    one_element dbms_xmldom.DOMElement;
    PROCEDURE p (msg VARCHAR2, nl BOOLEAN := TRUE) IS
    BEGIN
    dbms_output.put_line (msg);
    IF nl THEN dbms_output.put(CHR(10)); END IF;
    END:
    BEGIN
    doc := xml.parse(BFileName('XML_DIR','OpenXMLFile.xml'));
    node_list := xpath.selectNodes(doc, '/w:wordDocument/w:body/w:p/w:r/w:t');
    FOR j IN 0..dbms_xmldom.getLength(node_list)-1
    LOOP
    p( xpath.valueOf(dbms_xmldom.item(node_list, j), '.'), nl=>FALSE );
    END LOOP;
    Here is the error message.
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00601: Invalid token in: '/w:wordDocument/w:body/w:p/w:r/w:t
    [starts-with(., "!")]'
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 900
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 928
    ORA-06512: at "SYSTEM.XPATH", line 173
    ORA-06512: at "SYSTEM.XPATH", line 179
    ORA-06512: at line 38
    I really don't know why I got this error message nor how to solve it. If I remove "w:" manually within open xml file, then parsing works well. I guess XML parser for PL/SQL doesn't recognize ":" or maybe doesn't support namespace?
    My question is
    1. In oracle 10g release2, XML Parser for PL/SQL can recognize ":" in the element name? or does it support namespace? If not, is there any workaround for solving this problem?
    2. How can I make XML Parser recognize ":" in the element name in the xml file or How can I declare namespace in the PL/SQL code so that PL/SQL xml parser can recognize namespace like "w:"?
    In fact, I don't use XML DB and what I want to do is just to load XML file into the relational table and some parts of whole XML file will be inserted into the CLOB in the table.
    Should I really use XML DB to do the above job?
    Any comment or suggestions will be greatly appreciated.

    This works correctly. I added prefixes to your extract path. (I had to add the xmlns:xsi to your root node also.)
    declare
      -- Local variables here
       doc_in       dbms_xmldom.DOMDocument;
       aNodeList    dbms_xmldom.DOMNodeList;
    begin
      -- Test statements here
      doc_in := dbms_xmldom.newdomdocument(
    '<?xml version="1.0" encoding="UTF-8"?>' ||
    '<ap:Collection xmlns:ap="http://www.abc.com/ap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.abc.com/ap template.xsd"> ' ||
    '<ap:info>' ||
    '<ap:data name="Barbie" age="3">' ||
    '</ap:data>' ||
    '</ap:info>' ||
    '</ap:Collection>');
      aNodeList := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(doc_in),
                                                 '/ap:Collection/ap:info',
                                                 'xmlns:ap="http://www.abc.com/ap"');  
      dbms_output.put_line('length of aNodeList = '|| dbms_xmldom.getLength(aNodeList) );
    end;

  • There is a xml parser written in pl/sql

    Hi everybody,
    We know xml parser for pl/sql is based on xml parser for java, that is, we need the Jsever running. However, Jserver needs 60-80 MB of memory and initially we don't need Jserver, except for xml parsing. Then:
    There is a xml parser written in pure pl/sql ?.
    Thanks for your help!
    Jairo.

    PL/SQL is not sufficient to write for XML Parsing. The implementation is either in C or in Java.
    If you use Oracle9i, you can take use of XMLType for the C-based XML Parser.

  • XML parser with document support

    Hi all,
    For a whole week now, I m still looking for a nice (but lite) XML parser for J2ME applications. Of course I found kXML 2 parser but I'm confused.
    kXML 2 implements the XmlPull API (xmlpull.org) so you can parse easly an XML file with functions as next(), ...
    BUT, I would like to deal with a Document Object Model (DOM) (like JDom for J2SE), with this I will be able to do some nice stuff like doc.getRoot().getElement....
    In kXML2 Javadoc I found something like this but apparently it doesnt work well (or I dont know how to use it).
    Do someone know this API ? http://kxml.sourceforge.net/kxml2/javadoc/
    I can't find any example on Internet, everybody seems to use it without DOM....
    Until someone give me an answer I will continue to use kXML2 without document object model :(
    thanks guys,

    just a search..in http://sourceforge.net/
    http://sourceforge.net/search/?type_of_search=soft&type_of_search=soft&words=dom+j2me

  • XML Parsing with XSL Performance lag

    Hi there
    I should qualify this post by saying I am fairly new to EJB's and have based the below on a Java Working with XML Tutorial I read.
    I have an EJB which is being developed to parse XML documents with an XSL stylesheet and return HTML for display. The code is working fine however there is a fairly hefty performance lag when using the EJB to generate the HTML as opposed to the straight HTML. I am getting an average response time of 95000ms using the EJB as opposed to 45000ms when viewing the straight HTML. The code I am using to do the parsing is :
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(dataFile);
    // Convert docs into StreamSource
    StreamSource stylesource = new StreamSource(styleSheet);
    StreamSource source = new StreamSource(dataFile);
    StringWriter strWrite = new StringWriter();
    StreamResult result = new StreamResult(strWrite);
    // Use a Transformer for output
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(stylesource);
    transformer.transform(source, result);
    There is then some error handling and the strWrite object is placed into an array to be returned.
    I am really looking to find out if the performance lag I am experiencing is normal or if there is anything I can do to improve the speed of the code.
    All comments and help is most appreciated.
    Cheers
    Justin.

    You should be able to increase performance by caching Templates objects in memory as a previous post suggested.
    Here is some untested code:public final class TransformerCache
         private static Map cache = new Vector();
         private TransformerCache(){}
         public static Transformer getTransformer( String filename )
              if( ! cache.containsKey( filename ) )
                   TransformerFactory tf = TransformerFactory.newInstance();
                   Templates template = tf.newTemplates( new StreamSource( filename ) );
                   cache.put( filename, template );     
              return ( ( Templates ) cache.get( filename ) ).newTransformer();
    }This aproach works in a clustered environment, just bear in ming that there will be an instance of the cache on each server instance (virtual machine).

  • Using a xml parser with jbuilder

    I'm using jbuilder and the required librairies I've just added require me to add an XML parser to the path. I've just downloaded one from www.apache.org.
    How do I incorporate this parser into my project. I need to use the following packages but I'm not sure how I can put everything together.
    If you understand what my problem is please help. Thanks , B.
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;

    Go to tools | configure libraries.
    click the new button on the left
    Type in the name you want the library to be identified with (XML Parser or something)
    Choose the location (this determines how many people and projects have access to the libraries)
    Click the add button and find the *.jar files.
    Ok back out of the dialogs
    Now select the Project Properties (or default props to have the library available to all projects, not recommended tho)
    Select the paths tab
    Click Add and select the Library you added in the earlier steps.
    If you have any probs, www.borland.com has heaps of stuff on configuring libraries

  • XML Parsing with Tags increasing in no's

    I have an XML that I am recieving it from other system like below :
    <ResultSet>
      <ERROR_CODE_ID>0</ERROR_CODE_ID>
      <ERROR_DESCRIPTION>Success</ERROR_DESCRIPTION>
    <Rows>
    <Row1>
      <RATE_EFFECTIVE_DT>2013-08-24
    00:00:00.0</RATE_EFFECTIVE_DT>
    <INDEX_NAME>LN-EBOR-7D-AED              
    </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>7D</TERM>
      <TERM_NO>7</TERM_NO>
      <TERM_PERIOD>D</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.15430000</RATE>
    </Row1>
    <Row2>
      <RATE_EFFECTIVE_DT>2013-08-26
    00:00:00.0</RATE_EFFECTIVE_DT>
      <INDEX_NAME>LN-EBOR- 1M-AED  
               </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>1M</TERM>
      <TERM_NO>1</TERM_NO>
      <TERM_PERIOD>M</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.52430000</RATE>
    </Row2>
    <Row3>
      <RATE_EFFECTIVE_DT>2013-08-25
    00:00:00.0</RATE_EFFECTIVE_DT>
    <INDEX_NAME>LN-EBOR-2M-AED              
    </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>2M</TERM>
      <TERM_NO>2</TERM_NO>
      <TERM_PERIOD>M</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.66710000</RATE>
    </Row3>
    <Row4>
      <RATE_EFFECTIVE_DT>2013-08-24
    00:00:00.0</RATE_EFFECTIVE_DT>
      <INDEX_NAME>LN-EBOR-
    3M-AED             
    </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>3M</TERM>
      <TERM_NO>3</TERM_NO>
      <TERM_PERIOD>M</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.86140000</RATE>
    </Row4>
    <Row5>
      <RATE_EFFECTIVE_DT>2011-05-23
    00:00:00.0</RATE_EFFECTIVE_DT>
      <INDEX_NAME>LN-EBOR-
    4M-AED             
    </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>4M</TERM>
      <TERM_NO>4</TERM_NO>
      <TERM_PERIOD>M</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.0</RATE>
    </Row5>
    </Rows>
    </ResultSet>
    The data is comming in multiple row tag with Row1,Row2,Row3...so on.
    I am not able to parse the XML with Row1,Row2..etc. I need some help.

    Do you want to do this using Oracle database (which version?), or some other tools ?

  • XML Parsing with namespace

    Hi All,
    I have a requirement to convert XML to itab to be processed further.
    I couldn't parse the XML which contains ns0 (namespace?) as following:
    <ns0:OrderNo>887140</ns0:OrderNo>
    <ns0:CPROD>BD</ns0:CPROD>
    <ns0:CURR>USD</ns0:CURR>
    I'm able to parse If I remove the namespace ns0 from the file as following:
    <OrderNo>887140</OrderNo>
    <CPROD>BD</CPROD>
    <CURR>USD</CURR>
    The thing is the XML file will always come with the namespace ns0.
    I'm using IF_IXML, IF_IXML_STREAM_FACTORY, IF_IXML_ISTREAM, IF_IXML_PARSER, IF_IXML_DOCUMENT to parse the XML.
    Any idea on how to overcome this?
    Thanks,
    Victor.

    Hello Victor,
    fine. I am glad, I could help you.
    Just one note to XSLT Transformations: When using them, you got even the ability to map directly to internal abap tables:
    CALL TRANSFORMATION ZXSLT_YOUR_TRANSFORMATION
      SOURCE XML l_xmlstring
      RESULT DATA = lt_data.
    You just need to transform you xml to the asx:abap name space and that's it
    Look at Re: Help needed XML to Internal table and vice versa, where I show a simple example, how this works.
    Kind regards,
    Hendrik

  • XML parsing with digester

    Hi all,
    I'm trying to parse the following xml document:
    <?xml version="1.0" encoding="UTF-8"?>
    <map>
         <entry key='PAGE2.SNOME'>
              <bean key='nomeCliente'>field</bean>
         </entry>
         <entry key='PAGE3.TIPO_CONSTRUCAO'>
              <bean key='tipoConstrucao'>radio</bean>
         </entry>
    </map>with Digester. I'm trying to create a Map that holds Maps as Objects. My first approach was:
    Digester digester = new Digester();
    digester.addObjectCreate("map", HashMap.class);
    digester.addObjectCreate("map/entry", HashMap.class);
    digester.addCallMethod("map/entry", "put", 2);
    digester.addCallParam("map/entry", 0, "key");
    digester.addCallMethod("map/entry/bean", "put", 2);
    digester.addCallParam("map/entry/bean", 0, "key");
    digester.addCallParam("map/entry", 1);But it didn't return the results i expected. Is the order of the instructions wrong? What do i have to change to fix it?
    Hope someone can help me with this.
    Cheers,
    Carlos Ferreira

    Element rootelement = document.getDocumentElement();
    mainNodes = rootelement.getChildNodes();
    for(int i = 0; i<mainNodes.getLength(); i++) {
       Node eachParent = mainNodes.item(i);
       if(!eachParent.getNodeName().equals("#text")) {
          System.out.println(eachParent.getNodeName());
          for(Node child= eachParent.getFirstChild(); child != null; child=child.getNextSibling()) {
             if(!child.getNodeName().equals("#text")) {
                System.out.println(child.getNodeName()+" --- "+child.getFirstChild().getNodeValue());
    }This (your) code will only process the directchild nodes of your rootelement!
    try something like this instead:
    public void processDocument(Document document) {
       processElement(document.getDocumentElement();
    public void processElement(Node node) {
       if(!(node instanceof TextNode)) {
          System.out.println(eachParent.getNodeName());
          NodeList nodeChildren = node.getChildNodes();
          for(int i=0; i<nodeChildren.getLength(); i++) {
             proecessElement(nodeChildren.item(i));
    }

  • XML parsing with DocumentBuilder

    Hi,
    I use to parse an XML document using DocumentBuilder and Document objects.
    When i have within my XML document the following line :
    <value>MY_VALUE</toto>
    How can i get the value "MY_VALUE" using Node objects without searching elements by tag name or criteria ???
    Chris

    Parse document with dom4j parser and get the tag value with xpath.
    http://www.dom4j.org/guide.html

  • Java XML parsing with Xerces in Eclipse using Oxygen problem

    Hey everybody,
    Got me a stickler of a prob here and i'm hoping sum one out there will be able to help. I am trying to parse XML files into JDom objects so i can use them in the rest of my project with ease, but i'm having trouble parsing anything wihtout getting these errors
    Error: URI = /filelocat/personal-schema.xml", Line = "3", : Document root element "personnel", must match DOCTYPE root "null".
    Error: URI = /filelocat/personal-schema.xml", Line = "3", : Document is invalid: no grammar found.
    Error: URI = /filelocat/personal-schema.xml", Line = "3", : cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'personnel'.
    Error: URI = /filelocat/personal-schema.xml", Line = "3", : cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'personnel'.
    The are the files are ones that come in Oxygens samples folder so they should be correct. The code is as follows
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              factory.setValidating(true);
    SchemaFactory sFact = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    Schema schema = sFact.newSchema(schemaFile);
    factory.setSchema(schema);
    DocumentBuilder dommer = factory.newDocumentBuilder();          
    Document doco = dommer.parse(xmlFile.getAbsolutePath());None of these errors appears to be fatal, i can still use the doco object and extract the information i require, but i want to understand where the errors are coming from. There must be a parser setting or sumthing i've missed somewhere.
    Can anyone help?
    Any ideas/surgestions/critique welcome.
    Tom

    When we are parsing this xml: "<CustomerInfo><VCID/>77888</CustomerInfo>".
    See comments in following code.
    Element docEle = d.getDocumentElement(); // Returns "CustomerInfo" element node.
    NodeList childNodes2 = docEle.getChildNodes(); // Returns two nodes: <VCID/> element node and 77888 text node.
    Node item4 = childNodes2.item( 0 ); // First node (element node) of the "CustomerInfo" tag. <VCID/>
    Node item5 = childNodes2.item( 1 ); // Second node (text node) of the "CustomerInfo" tag is 77888. Look this text is not child of VCID, it's second child node of "CustomerInfo" tag.
    NodeList childNodes3 = item4.getChildNodes(); // Returns null because <VCID/> node is empty.
    String nodeValue = item5.getNodeValue(); // Returns 77888 ( text node ).               Regards,
    S&#322;awomir Wojtasiak

  • Simple XML parsing with DOM

    I have a XML file i need to parse. Can please someone give me a hint how to do this(please include code). Please note that im a new in XML and my DOM structure knowledge in limited(im confused from all the tutorials).
    XML code:
    <Vitals>
    <Hostname>sometest</Hostname>
    <IPAddr>sometest</IPAddr>
    <Kernel>sometest</Kernel>
    <Uptime>sometest</Uptime>
    <Users>sometest</Users>
    <LoadAvg>sometest</LoadAvg>
    </Vitals>
    <Network>
    <NetDevice>
    <Name>lo</Name>
    <RxBytes>10425010</RxBytes>
    <TxBytes>10425010</TxBytes>
    <Errors>0</Errors>
    <Drops>0</Drops>
    </NetDevice>
    <NetDevice>
    <Name>eth0</Name>
    <RxBytes>627976843</RxBytes>
    <TxBytes>2394415516</TxBytes>
    <Errors>271</Errors>
    <Drops>0</Drops>
    </NetDevice>
    </Network>
    So far ima at this step:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    try {
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse( new File("NewFile.xml") );

    Just as simple text in console.
    Please give me the code.
    Is there any diference in document (DOM) if you create it with DFD or w/h ?
    So far i have this code, but it dosnt work for me(i get nothing as output:
    document = builder.parse( new File("NewFIle.xml") );
    NodeList list = document.getElementsByTagName("coffee");
    // Loop through the list.
    for (int k=0; k < list.getLength(); k++) {
    Node thisCoffeeNode = list.item(k);
    Node thisNameNode = thisCoffeeNode.getFirstChild();
    if (thisNameNode == null) continue;
    if (thisNameNode.getFirstChild() == null) continue;
    if (! (thisNameNode.getFirstChild() instanceof org.w3c.dom.Text)) continue;
    String data = thisNameNode.getFirstChild().getNodeValue();
    System.out.println(data);
    }

  • Xml parsing with Java

    Hi ..!
    I am having a small problem friends if anybody of you can just help me resolving this .
    I am quiet new to working with parsing XML with SAX and Dom java parsers .
    Problem is when we want to extract the Element name ,Attribute Name or Attribute Value it is quiet simple in Java to do so .
    But supposing i want to extract the value between the tags of an element how can we do so either their is a simple method that i have missed or their is a tedious procedure that i am ignorant of.
    eg- <Node1> this is my name <Node1>
    Java source output -this is my name.
    Thanx to you people for co-operating
    Take care
    Akshat

    in SAX u can do like this
         boolean nodeflag=false;
         public void startElement(String uri,String localName, String qName,Attributes attributes)throws SAXException
              if(qName.equals("Node1"))
                   nodeflag=true;
         public void endElement (String uri, String localName, String qName)throws SAXException
              if(qName.equals("Node1"))
                   nodeflag=false;
         public void characters(char[] ch, int start,int length)throws SAXException
              String s=new String(ch,start,length);
              if(nodeflag==true)
                   if(!s.trim().equals(""))
                        System.out.println(s.trim());
         }here in characters method u can work with data

  • XML parsing with DOM

    I'm using xerces to parse an XML file and am running in to trouble. Do you have to parse child nodes before attributes? I do this in every node except for one called "table" in my parser. However, I have an abstract class called "Table" that is subclassed by Table1D and Table2D, and I need to parse the attributes to know which to instantiate.
    The problem is, I have a child node called scale. For some reason, scale is being parsed as if it were a table.
    Here is a look at my unmarshallTable method. Ignore the lack of exception handling.
    private Table unmarshallTable(Node tableNode) {
         Table table;
            if (unmarshallAttribute(tableNode, "type", "unknown").equals("3D")) {
                table = new Table3D();
            } else if (unmarshallAttribute(tableNode, "type", "unknown").equals("2D")) {
            } else {
                //exception
                return null;
            table.setName(unmarshallAttribute(tableNode, "name", "unknown"));
            if (table.getType().equals("2D")) {           
                ((Table2D)table).setFlipX(Boolean.parseBoolean(unmarshallAttribute(tableNode, "flipx", "unknown")));
         Node n;
         NodeList nodes = tableNode.getChildNodes();
         for (int i = 0; i < nodes.getLength(); i++) {
             n = nodes.item(i);
             if (n.getNodeType() == Node.ELEMENT_NODE) {
              if (tableNode.getNodeName().equals("table")) {
                  if (table.getType().equals("2D")) {
                            if (unmarshallTable(n).getType().equals("Static Y Axis")) {
                                ((Table2D)table).setStaticYAxis((Table1D)unmarshallTable(n));
                        }  else if (table.getType().equals("3D")) {
                            if (unmarshallTable(n).getType().equals("X Axis")) {
                                ((Table3D)table).setXAxis((Table1D)unmarshallTable(n));
                            } else if (unmarshallTable(n).getType().equals("Y Axis")) {
                                ((Table3D)table).setYAxis((Table1D)unmarshallTable(n));
                    } else if (tableNode.getNodeName().equals("scaling")) {
                        table.setScale(unmarshallScale(n));
              } else {
                  // unexpected element in Article
             } else {
              // unexpected node-type in Article
         return table;
        }  

    Doh! I got it.
    if (tableNode.getNodeName().equals("table")) {
    should be
    if (n.getNodeName().equals("table")) {                                                                                                                                                                                                                                   

  • XML Parsing with Java - Only some attributes have start and end tags

    Hello,
    I am trying to interpret the XML response from a server after a HTTP request is sent to it. I have modified an example off Wikipedia below to give an example of what it looks like.
    Example XML:
    <Asset name="bread" prep_time="5 mins" cook_time="3 hours">
    <Attribute name="Ingredient: ">Flour</Attribute>
    <Attribute name="Ingredient: ">Water</Attribute>
    <Attribute name="Used in Recipes:" />
    </recipe>
    I have been trying to display the above XML in a format such as:
    name: bread prep_time: 5 mins cook_time: 3 hours
    Ingredient: Flour
    Ingredient: Water
    Used in Recipes:
    Right now I have been trying to do it manually using indexOf and substring of the XML text, but I would like to find a better way of doing this. I have found some examples online that show had to deal with cases such as
    <person>
    <first>Kiran</first>
    <last>Pai</last>
    <age>22</age>
    </person>
    but I do not know what to do when I encounter something like the last item, when there are no "Used in Recipe" items, and it ends with a />, instead of an ending tag </Attribute>.
    Are there any suggestions as to how to handle the example XML code that I have posted?
    Any help would be appreciated. Thanks.

    jtahlborn wrote:
    Tolls wrote:
    I suppose so, but since the idea is to turn it into text in a different format, XSLT strikes me as a better fit than hand crafting it.i agree if the end goal is formatted text. however, i wasn't sure if the OP was just writing some test code to figure out how to access the data or if the formatted text was the final desired output.No, true. It is open to interpretation.
    jschell wrote:
    (Quoting the same bit)
    As long as one is mindful of the potential performance and maintenance impacts of course.Again, it depends what he's doing...true. I was making some assumptions, since (as usual) we don't really know the requirements beyond a base technical one (ie "I have this, and I need it to look like this"). In general, though, if you have XML data and you need it formatted differently then I'd say your first port of call ought to be transformation.
    As for maintenance, I'd say it's easier to maintain a stylesheet than to modify Java, which is why I say it ought to be the start point.
    Of course, YMMV.

Maybe you are looking for

  • Fields for a Purchase order

    Hi, I have got a requirementon smartform, but I have not received Fields. Could anybody give me the fileds for a Purchase order Like :                 SERVICE ORDER             - ?      SERVICE Technicain Name -  ?      Sales Order             - ?   

  • Using CONVERT_OTFSPOOLJOB_TO_PDF

    Hello, I would like to use the function module CONVERT_OTFSPOOLJOB_TO_PDF through a RFC connection. in order to create a PDF file from a the spool ! Am I right ? or have I to do in an other way ? But the PDF output seems to be bad. Regards, Smoltok

  • Dreamweaver CS5 Slow to Open File... Enable Related Files

    Hello, I have a page that uses the Fancybox script and it takes Dreamweaver 50 seconds to open this page. This script requires jQuery, so in the head of my page I have this: <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.

  • OS X Server 10.6.4 - newly created user cannot login to server

    As title. Just turn on the mac mini server (mid-2010) and do some initial setup. It can access the internet. However, all users that I have created cannot log into the server! Only the one (admin account) that created during the 1st time server setup

  • To save survey in the ITS

    Hi experts. I have created an activity in CRM with a survey . I access to the CRMD_ORDER by ITS. I create an activity that have a survey when I try to save the survey it is releaded to the next page: res://ieframe.dll/unknownprotocol.htm#sapevent:WFF