Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XML Blackberry
Hi i want to parse xml .here is my xml . please help me .
 
main xml is
            <characteristicvalue>
               <characteristic>
                  <name>ResourceFacingServiceInstance.PortProfileInstance.UpstreamIsTrellisEnabledCode</name>
               </characteristic>
               <value>true
			   </value>
            </characteristicvalue>
 

 

    <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:body>
          <re:queryresourceresponse xmlns:me="http://www.ibm.com/xmlns/prod/websphere/fabric/2008/12/telecom/operations/inventory/schema/ResourceConfigurationMessage" xmlns:re="http://www.ibm.com/xmlns/prod/websphere/fabric/2008/12/telecom/operations/inventory/types/schema/QueryResource" xmlns:v20="http://www.ibm.com/telecom/common/schema/mtosi/v2_0">
             &lt;header&gt;
                <v20:timestamp>2012-10-15T23:42:26.275Z</v20:timestamp>
                <v20:activityname>QueryResource</v20:activityname>
                <v20:communicationpattern>SimpleResponse</v20:communicationpattern>
                <v20:communicationstyle>MSG</v20:communicationstyle>
                <v20:msgspecificproperties>
                   <v20:property>
                      <v20:propname>DSLe provisioning_infoPortType.getLineInfo</v20:propname>
                      <v20:propvalue>SUCCESS</v20:propvalue>
                   </v20:property>
                   <v20:property>
                      <v20:propname>Name: DSLe pe_dataPortType.getData</v20:propname>
                      <v20:propvalue>SUCCESS</v20:propvalue>
                   </v20:property>
                   <v20:property>
                      <v20:propname>Instance: DSLe pe_dataPortType.getData</v20:propname>
                      <v20:propvalue>SUCCESS</v20:propvalue>
                   </v20:property>
                </v20:msgspecificproperties>
             &lt;/header&gt;
             <me:physicalresource>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.UpstreamIsTrellisEnabledCode</name>
                   </characteristic>
                   <value>true
                   </value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.UpstreamSupportedStandardsNumber</name>
                   </characteristic>
                   <value>20056</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.DownstreamMaxMarginNumber</name>
                   </characteristic>
                   <value>15.0</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.DownstreamMinMarginNumber</name>
                   </characteristic>
                   <value>0.0</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.DownstreamMaxRateNumber</name>
                   </characteristic>
                   <value>31520</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.UpstreamINPNumber</name>
                   </characteristic>
                   <value>2.0</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.PortProfileName</name>
                   </characteristic>
                   <value>26-31Mb_16ms_INP_2:8B_12DB</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.DownstreamMinRateNumber</name>
                   </characteristic>
                   <value>26240</value>
                </characteristicvalue>
               
               
              
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.UpstreamMaxPSDNumber</name>
                   </characteristic>
                   <value>-38.0</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.DownstreamInterleavingCode</name>
                   </characteristic>
                   <value>true</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.UpstreamMaxRateNumber</name>
                   </characteristic>
                   <value>3072</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.DownstreamTargetMarginNumber</name>
                   </characteristic>
                   <value>12.0</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.DownstreamIsTrellisEnabledCode</name>
                   </characteristic>
                   <value>true</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.DownstreamMaxPSDNumber</name>
                   </characteristic>
                   <value>-40.0</value>
                </characteristicvalue>
                <characteristicvalue>
                   <characteristic>
                      <name>ResourceFacingServiceInstance.PortProfileInstance.UpstreamMinRateNumber</name>
                   </characteristic>
                   <value>128</value>
                </characteristicvalue>
              
       
                <specification>
                   <type>Optimized DSL Port</type>
                   <category>Logical Resource</category>
                </specification>
             </me:physicalresource>
          </re:queryresourceresponse>
       </soapenv:body>
    </soapenv:envelope>
 
******************************************
Main code in in blackberry is
 
package mypackage;
 
import java.io.IOException;
import java.io.InputStream;
 
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.file.FileConnection;
 
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
 
import net.rim.device.api.io.File;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.xml.parsers.DocumentBuilder;
import net.rim.device.api.xml.parsers.DocumentBuilderFactory;
 
/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class MyScreen extends MainScreen
{
    /**
     * Creates a new MyScreen object
     */
	 Document doc;
     StreamConnection conn;
     HttpConnection hc = null;
     FileConnection fc=null;
    public MyScreen()
    {        
    	Connection  _connectionthread = new Connection();
        _connectionthread.start();
    
    }
    
    private class Connection extends Thread
    {
        public Connection(){
            super();
        }
 
        public void run()
        {
            
           
            try{
                
            	//Dialog.alert("hai");
               
            	
                DocumentBuilderFactory docBuilderFactory= DocumentBuilderFactory. newInstance(); 
                  
                DocumentBuilder docBuilder= docBuilderFactory.newDocumentBuilder();
                  
               
                FileConnection fc=(FileConnection)Connector.open("file:///SDCard/a.xml");
              InputStream  is=fc.openInputStream();
           doc= docBuilder.parse(is);
                doc.getDocumentElement ().normalize ();
                NodeList list=doc.getElementsByTagName("CharacteristicValue");
             String   _node=new String();
             String  _element = new String();
                
 
                for (int i=0;i<list.getlength();i++){>
                    Node value=list.item(i).
                      getChildNodes().item(0);
                    _node=list.item(i).getNodeName();
                    _element=value.getNodeValue();
                System.out.println("*****************_node+ value"+_node+_element);
                }//end for
            }//end try
            //will catch any exception thrown by the XML parser
            catch (Exception e){
                System.out.println(e.toString());
            }
        }//end connection function
    }// end connection class
    
}
Posted 12-Mar-13 22:49pm
Edited 12-Mar-13 23:43pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hello,
 
Your XML does not seems to have a root element. Remove following from your xml.
<characteristicvalue>
     <characteristic>
          <name>ResourceFacingServiceInstance.PortProfileInstance.UpstreamIsTrellisEnabledCode</name>
     </characteristic>
     <value>true</value>
</characteristicvalue>
Regards,
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 CPallini 155
3 PIEBALDconsult 150
4 BillWoodruff 148
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100