HELP: Using DOM in J2ME

I'm trying to use DOM in J2ME, but I'm unable to find a API that has a documentFactory. Can anyone help me?

"I'm using J2ME" isn't very informative, because there are a number of basic J2ME APIs, called profiles. For mobile phones it's generally MIDP (1.0 or 2.0); for devices like PocketPC it's as likely to be FP (Foundation Profile), PBP (Personal Basis Profile), or PP (Personal Profile), again having multiple versions.

Similar Messages

  • Need to retrieve all the node values of xml using DOM parser..pls help

    I want to fetch each node value in this xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <Main>
    <AAAAA>
    <ES>ESValue</ES>
    <EI>EIValue</EI>
    </AAAAA>
    <BBBBB>
    <SIP>
    <ST>STValue</ST>
    <TB>TBValue</TB>
    <PM>PMValue</PM>
    <VIP>
    <CARP>
    <AN1>AN1Value</AN1>
    <BN>BNValue</BN>
    </CARP>
    <DARP>
    <SA>
    <AN2>AN2Value</AN2>
    <CN>CNValue</CN>
    </SA>
    </DARP>
    </VIP>
    </SIP>
    </BBBBB>
    </Main>
    output should be the inner text values of diffrent nodes that contain some values..
    i.e
    output:
    ESValue
    EIValue
    STValue
    TBValue
    PMValue
    AN1Value
    BNValue
    AN2Value
    CNValue
    so that i can use thses node values and put it them in database...

    pls check the above xml file in proper redable order...I need to parse using DOM and fetch node values that are present...
    <?xml version="1.0" encoding="UTF-8"?>
    <Main>
        <AAAAA>
            <ES>ESValue</ES>
            <EI>EIValue</EI>
        </AAAAA>
        <BBBBB>
            <SIP>
                <ST>STValue</ST>
                <TB>TBValue</TB>
                <PM>PMValue</PM>
                <VIP>
                    <CARP>
                        <AN1>AN1Value</AN1>
                        <BN>BNValue</BN>
                    </CARP>
                    <DARP>
                        <SA>
                            <AN2>AN2Value</AN2>
                            <CN>CNValue</CN>
                        </SA>
                    </DARP>
                </VIP>
            </SIP>
        </BBBBB>
    </Main>

  • Using DOM

    Hi everyone,
    I was wondering if someone could give me a hand with the following.
    I am planning to create a simple search engine to search for products for a computer parts retailer. The list of products is stored in an XML repository , and all queries to this repository are sent as XML documents.
    The search engine web page will display a single text input field, into which a user can enter a keyword to search for
    I am using DOM to convert the Html search query to an XML document.
    Here is my DOM code so far.
    <%@page import="java.io.*"%>
    <%@page import="javax.xml.parsers.*"%>
    <%@page import="org.w3c.dom.*"%>
    <%@page import="org.apache.xml.serialize.*"%>
    <%!
    String 
    search,textfield;
    %>
    <%
    // Retrieve the Search query
    search = request.getParameter("search");
    textfield = request.getParameter("textField");
    // Create a new DOM factory, and from that a new DOM builder object
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();// Note that we are creating a new (empty) document
    Document document = builder.newDocument();
    // The root element of our document wil be <query>
    // It gets stored as the child node of the whole document (it is the root)
    rootElement = document.createElement("query");
    document.appendChild(rootElement);
    // Create an <searchterm> element , place underneath <query>
    Element searchtermElement = document.createElement("searchterm");
    searchtermElement.appendChild(document.createTextNode(searchterm));
    rootElement.appendChild(searchtermElem
    I am just wondering if my DOM code looks correct so far?

    A further cast didn't help either. For a change I have abandonded the JAXP approach and instead have built an example found at
    http://otn.oracle.com/pub/listings/vohra_xmlschema_l4.html
    that shows how to validate against a schema.
    I have changed the method to return the validated document and have then tried to apply some of the D0M validation methods supposed to return a NameList but I still always get null.
    I have posted the example Java program at
    http://home.arcor.de/martin.honnen/java/xml/Test20040308.java.txt
    and run it against the example schema and XML files at http://home.arcor.de/martin.honnen/java/xml/test20040307Xsd.xml http://home.arcor.de/martin.honnen/java/xml/test20040307.xml
    While the parsing works and the XML is judged valid according to the schema attempts to use the DOM validation methods to return a NameList fail to return one.
    Does anyone have an example using any DOM Level 3 validation interfaces/methods successfully?

  • Problem in parsing JMS TextMessages using DOM

    Hi
    I want to parse JMS TextMessages by using DOM parser.DomBuilder's parse method supports only Strings,input stream in its constructor.
    Is there anyway we can parse JMS TextMessages by using DOM.Your help would be appreciated.
    Thanks
    Kanth

    kanth218 wrote:
    Hi
    DomBuilder's parse method supports only Strings,input stream in its constructor.This is not true. Have another look at the documentation.
    Is there anyway we can parse JMS TextMessages by using DOM.Your help would be appreciated.
    parse(new InputSource(new StringReader(someString)))

  • Parsing xml using DOM parser in java

    hi there!!!
    i don have much idea about parsing xml.. i have an xml file which consists of details regarding indentation and spacing standards of C lang.. i need to read the file using DOM parser in java n store each of the attributes n elements in some data structure in java..
    need help as soon as possible!!!

    DOM is the easiest way to parse XML document, google for JDOM example it is very easy to implement.
    you need to know what is attribute, what is text content and what is Value in XML then easily you can parse your document with dom (watch for space[text#] in your XML document when you parse it).
    you get root node then nodelist of childs for root then go further inside, it is easy believe me.

  • How to remove element namespaces in XML file using DOM or SAX?

    Hi Guys,
    I developed a JAVA mapping in XI to add name spaces for XML file, after mapping,name spaces xmlns="http://www.mro.com/mx/integration" and xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" were added correctly, but for some nodes, such as <Header> and <Content>, a name space xmlns="" was added automatically.Please check below files to compare.
    It looks like be added automatically by XI. I didn't process anything for these nodes in JAVA program.
    Now the issue is, how can I remove these redundant namespaces? Such as xmlns="".
    Can I remove them using DOM or SAX in JAVA Mapping?
    Thanks in advance.
    ====>Original XML file
    <?xml version="1.0" encoding="UTF-8"?>
    <LLYLPPInterface language="EN">
       <Header>
          <SenderID>GBIP</SenderID>
          <CreationDateTime>2008-02-13T22:49:34-05:00</CreationDateTime>
          <RecipientID/>
          <MessageID/>
       </Header>
       <Content>
          <LLY-LPP>
             <INVOICE>
                <INVOICELINE>
                   <PONUM>4780000008</PONUM>
                   <POLINENUM>1</POLINENUM>
                   <INVOICEQTY>1</INVOICEQTY>
                   <LOADEDCOST>68</LOADEDCOST>
                </INVOICELINE>
             </INVOICE>
          </LLY-LPP>
       </Content>
    </LLYLPPInterface>
    ===>Target XML file after JAVA mapping
    <?xml version="1.0" encoding="utf-8"?>
    <LLYLPPInterface language="EN" xmlns="http://www.mro.com/mx/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <Header xmlns="">
              <SenderID>GBIP</SenderID>
              <CreationDateTime>2008-02-13T23:11:55-05:00</CreationDateTime>
              <RecipientID/>
              <MessageID/>
         </Header>
         <Content xmlns="">
              <LLY-LPP>
                   <INVOICE>
                        <INVOICELINE>
                             <PONUM>4780000008</PONUM>
                             <POLINENUM>0</POLINENUM>
                             <INVOICEQTY>1</INVOICEQTY>
                             <LOADEDCOST>68</LOADEDCOST>
                        </INVOICELINE>
                   </INVOICE>
              </LLY-LPP>
         </Content>
    </LLYLPPInterface>
    Edited by: Eddie Zhang on Feb 14, 2008 9:22 AM
    Edited by: Eddie Zhang on Feb 14, 2008 9:24 AM

    Hi Milan,
    Thanks for your replay.
    Actually when I used module XMLAnonymizerBean to convert namespaces, the header of XML, such as <?xml version="1.0" encoding="UTF-8"?> was converted to format <?xml version='1.0' encoding='UTF-8'?>, quote was converted to single quote. Although I set parameter anonymizer.quote = ", it still didn't work, single quote appeared instead of quote.
    I'm not sure why this happened. Can anyone help to clarify this?
    Thanks
    Edited by: Eddie Zhang on Feb 15, 2008 2:11 AM

  • Convertion of flat file to XML using DOM

    Hi!
    I need help for convert a flat file to XML using DOM and by taking the validation of a specified DTD. Can any body help me in this regard.
    Bye,
    lat

    first you have to decide how the flat file will map to xml. Will you use attributes or pcdata for your fields, or both? Will there be a hierarchy, or will it be mostly flat?
    Once decided, you'd probably just use a BufferedReader to read the lines one at a time, and generate Dom nodes as appropriate, and stick them in the tree.

  • How to ignore empty text element while using DOM to parse xml??

    hi everyone,
    i am using DOM to parse an xml file. But i dont know how to cinfig the DocumentBuilderFactory to ignore empty text elements.
    For example, i have an xml file like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <root>
        <child>Tom</child>
        <child>Jerry</child>
    </root>I used the following codes to parse:
    String fname = "Tom-and-Jerry.xml";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    // Generate a DOM tree from the DOM builder.
    org.w3c.dom.Document dom = builder.parse(new File(fname));
    org.w3c.dom.NodeList list = dom.getChildNodes();
    for (int i=0; i<list.getLength(); i++) {
        System.out.println("Child No."+i);
        System.out.println("NodeName="+list.item(i).getNodeName());
        System.out.println("NodeType="+getType(list.item(i).getNodeType()));
        System.out.println("NodeValue="+list.item(i).getNodeValue());
        System.out.println();
    }The result is not exactly what i want ---- there are 5 children in list!! The 1st, 3rd and 5th are #text and their values are all empty. Only the 2nd and the 4th are the child that i expect.
    It is really troublesome to get all these silly empty texts as sub elements. I tried to get rid of them, but i failed. I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.
    Anyone can help me? thanks.
    Heavy ZHENG

    I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.That only does something if the XML has a DTD that enables it to know what whitespace can be ignored and what is significant. The API documentation for the method refers you to this document:
    http://www.w3.org/TR/REC-xml#sec-white-space

  • Update XML using DOM parser

    I am using Dom parser in java to parse xml.I am able to retrive data from xml.Can any one help me in updating an xml when data is modified in the user interface.I am created interface in html with three fields namely UserName , LastLogin, Modified fields.If Admin person wants to modify any of these three fields , those changes should reflect in xml also.
    Thanks
    divya

    Code snippet
    ===========
    OutputFormat outputFormat = new OutputFormat("XML","ISO-8859-1",true);
    outputFormat.setDoctype(null,"emp.dtd")
    It adds the DOCTYPE element but doesnt create the .DTD file.
    <!DOCTYPE ROOT_EL SYSTEM "emp.dtd">
    Any ideas?
    Rgds,
    Seetesh

  • Namespace declaration using DOM

    Hi,
    I am using DOM to create an XML document. How do I declare namespace?
    I want to know which API is used to create namespace declaration in an XML document.
    I want my final XML document to be
    <RootElement xmlns:c="http://pradeep.somesite.com">
    <name>pradeep</name>
    <RootElement>
    My problem is how to put the xml ns declaraton in RootElement.
    Some one plz help;
    thanks in adv.

    xmlns is like any other attribute.
    Try something like:
    NamedNodeMap attributes = rootElement.getAttributes();
    Attr namespace = myDoc.createAttribute("xmlns");
    namespace.setValue("........");
    attributes.setNamedItem(namespace);

  • Displaying a matrix using DOM

    hi group,
    this is satya chowdhury .i am facing some problem in how to parse a matrix using dom.the xml file is as follows:-
    <?xml version="1.0" ?>
    - <matrix>
    <rows>4</rows>
    <columns>4</columns>
    - <row>
    <column>11</column>
    <column>12</column>
    <column>13</column>
    <column>14</column>
    </row>
    - <row>
    <column>21</column>
    <column>22</column>
    <column>23</column>
    <column>24</column>
    </row>
    - <row>
    <column>31</column>
    <column>32</column>
    <column>33</column>
    <column>34</column>
    </row>
    - <row>
    <column>41</column>
    <column>42</column>
    <column>43</column>
    <column>44</column>
    </row>
    </matrix>
    and the program is as follows
    import java.io.File;
    import java.io.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.ErrorHandler;
    public class Matadd
         static Document doc;
    static int mat[][]=new int[0][0];
         public static void main(String arg[])
              DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
              try
              DocumentBuilder builder=factory.newDocumentBuilder();
              builder.setErrorHandler(new Terror());
              doc=builder.parse(new File("mat.xml"));
              Element root=doc.getDocumentElement();
              NodeList list=doc.getElementsByTagName("row");
              int i=list.getLength();
              System.out.println("THE NO.OF ROWS IN THE GIVEN MATRIX--->"+i);
              NodeList list1=doc.getElementsByTagName("column");
              int j=list.getLength();
              System.out.println("THE NO.OF COLUMNS IN THE GIVEN MATRIX--->"+j);
    for(int row=0;row<i;row++)
    for(int col=0;col<j;col++)
         Node node=list1.item(col).getLastChild();
              System.out.println(""+node.getNodeValue());
              catch(SAXException e)
              catch(IOException e)
              catch(ParserConfigurationException e)
              static class Terror implements ErrorHandler
                                  public void fatalError(SAXParseException e)
                                       System.out.println("error:"+e);
                             public void error(SAXParseException e)
                                       System.out.println("error:"+e);
                                  public void warning(SAXParseException e)
                                            System.out.println("error:"+e);
    BUT IS IS NOT ITERATING ALL THE ROWS.PLZ HELP ME.I HAVE TO SUBMIT THE ASSIGNMENT TODAY.
    BYE
    SATYABRATA
    [email protected]

    i have modified ur cod e..this is working..i have created on recursive function that will iterate through ur colum values...
    any comments please let me knoe
    reagards
    shanu
    [email protected]
    import java.io.File;
    import java.io.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.ErrorHandler;
    * @author sm23772
    * TODO To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Style - Code Templates
    public class SimpleParse {
         static Document doc;
         static int mat[][]=new int[0][0];
         public static void main(String[] args) {
              DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
              try
              DocumentBuilder builder=factory.newDocumentBuilder();
              doc=builder.parse(new File("test.xml"));
              Element root=doc.getDocumentElement();
              NodeList list=doc.getElementsByTagName("row");
              int i=list.getLength();
              System.out.println("THE NO.OF ROWS IN THE GIVEN MATRIX--->"+i);
              NodeList list1=doc.getElementsByTagName("column");
              int j=list.getLength();
              System.out.println("THE NO.OF COLUMNS IN THE GIVEN MATRIX--->"+j);
              for (Node child = root.getFirstChild();
    child != null;
    child = child.getNextSibling())
    if(child.getNodeName().equals("row"))
         getValues(child); //calling my recursive funciton
    /************** instead of this i have made small funciton ******************/
              /*for(int row=0;row<i;row++)
              for(int col=0;col<j;col++)
              Node node=list1.item(col).getLastChild();
              System.out.println(""+node.getNodeValue());
    System.out.println("");
              catch(Exception e)
                   System.out.println(e);
    public static void getValues(Node start)
    if(start.getNodeName().equals("column"))
    System.out.println(start.getFirstChild().getNodeValue());
    for (Node child = start.getFirstChild();
    child != null;
    child = child.getNextSibling())
         getValues(child);
    }

  • How to develop VoIP client using SIP in J2ME?

    Hi Everybody,
    I want to develop a VoIP client in J2ME that connects to asterisk server of debian and can call to the registered user of asterisk server and can have a telephonic talk session easily.
    Do anybody have idea regarding the development of the client or having tutorial that teaches the development of VoIP in J2ME or in any other way.?
    PLZ help me to provide the solution.
    Thanks in anticipation.
    with regards,
    KHAKHAR SAGAR

    Hi
    I am interested about developing VoIP application (using SIP) in J2ME platform. But I am stuck with the problem of MMAPI. Without using MMAPI J2ME has no access to mobile media devices, such as speaker or microphone, and without creating a player MMAPI can't play media data, such as sound or video. But its not possible to record voice and play voice data simultaneously using player in J2ME. So it seems almost impossible to implement VoIP application maintaining all its constraints and requirements, specially in case of delay and jitter.
    I am looking for some solution, which will provide the ability to overcome this problem. I come out with two possible solutions, but not sure about their out come. If we can develop a native media application, we can have access to it by using KNI (K Native Interface). In that way we can take some risk to develop VoIP application for J2ME. My another solution is, we can handle the player using MMAPI to record and play voice data in mill second level, so that we can have a real time feeling, though I am not sure if its possible by using RTSP.
    If any one have solution of this problem, please help us.
    Reagards
    Asif Mohammed Adnan

  • Help in DOM

    Hi,
    I am generating a XML using DOM (org.w3c.dom ) which holds the form values.
    The XML schema is like this
    <root>
    <data>
    <id>1</id>
    <check>True</check>
    </data>
    <data>
    <id>2</id>
    <check>false</check>
    </data>
    </root>
    What im doing in my code -
    I/P : Request parameter Values obtained from FORM
    o/p: XML String
    1)Create a root node
    2)Create a Node called data
    3)Create an id node and set the value obtaining from the Request parameter. Then append this node to data node
    4)Similary create the check node,set its value based on some calculation and append this to data node.
    5) Then attach the data node to Root node
    Finally attach the Root node to the Document and later i convert this Documemt to String using serialization.
    Problem here is sometimes based on Request parameter value, i want to check the id node created already and compare with the request value. If it matches, then i have to append a new node in the data node something like this :
    Request value is 2 and ID node value is 2. hence append a new node
    <data>
    <id>2</id>
    <check>false</check>
    <newnode>test </newnode>
    </data>
    But how can i get the ID node,check its value ,compare with the request value and if it matches attache a new node as the Document at this point of time is not yet constructed. ie The data nodes are keep on attached to the root node and only finally the root node is attached to the Document.
    Could anyone please help how to solve this problem . Please ask me if you are not clear.
    Thanks in advance

    Why don't you create a blank DOM document and than add root node and other nodes?
    http://www.roseindia.net/xml/dom/

  • Updating XML file using DOM parser

    Hi,
    Can someone help me, how to update following XML file using DOM parser.
    The following is my XML file.
    <students>
         <student>
              <id>1</id>
              <name>abc</name>
         </student>
         <student>
              <id>2</id>
              <name>xyz</name>
         </student>
         <student>
              <id>3</id>
              <name/>
         </student>
         <student>
              <id>4</id>
              <name>ijk</name>
         </student>
         <student>
              <id>5</id>
              <name></name>
         </student>
    </students>Consider, I will input 2 fields, ie., id & name. For the matching Id, the name has to be updated.
    Though, I have achieved this, but I am unable to update the value for 3rd record, & 5th record ie., id=3 & id=5. Since, these are blank.
    Thanks.

    Some <name> elements have a child node which is a text node. From what you say it appears you know how to change those text nodes.
    The other <name> elements don't have any child nodes. But you want one. This suggests to me that you need code that creates a text node and adds it to the <name> element as its child.

  • How to insert ascii characters using dom

    I am having a tough time inserting ascii values in to xml text content
    i search for a regular space and try insert a non breaking space in my xml whic is basically �
    Infact I want to insert the ascii value of a non breaking space or for that matter ascii value of any character, I am using dom level 2.
    in the code the actual replace ment string is the ascii code, somehow when I click preview, it actually shows the space instead showing the what I have in my actual code, so i had to separate in the ascii and ; in my code snippet that follows
    String text = nl.item(i).getNodeValue();
                System.out.println(text);
                String newText  = text.replaceAll("\\s", "� followed by a ;");
                nl.item(i).setNodeValue(newText)it actually inserts &#160; in the xml code for the xml document and literally "&#160 followed by ;" appears in my document when viewed from a browser, all I am trying to do is replace a given character with an ascii value using dom. All i tried to do was replace a regular space with a non breaking space.
    &nbsp won't work either, infact i tried ascii values for other characters too, i end up having the ascii value in the tag when i view the finished document in a browser.
    Please help
    Edited by: jaks4u on Mar 22, 2008 2:23 PM

    As jtahlborn says, NBSP isn't an ASCII character. But this is Java we're working with, and XML. Neither of those two things have ever restricted themselves to the ASCII character set, and neither should you. They use Unicode, which is far larger and which does include that character. You could go to [the Unicode site|http://www.unicode.org/] and do some research -- which might broaden your horizons a lot -- but the code point for that character is (not surprisingly) 160. That's A0 in hexadecimal, so the Java character representing it ischar nbsp = '\u00a0';So use that in your code. Just make sure to output the XML document in an encoding that supports it (unlike ASCII). UTF-8 would be an excellent choice.

Maybe you are looking for