Parses a string with a SAX parser

Hello

I developed a returned from the XML web service. This XML file is intended to be analyzed by the blackberry.

I am currently unable to deploy the web service, that what I did to test it is copy the result in a string and store it in the program.

When I try to analyse if I get an exception: SaxParseException: wait until the end of the file (I watched with the debugger and the row and the column of two exceptions are - 1).

String test = Oas.DUMMY_ANSWER;
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
System.out.println("DEBUG: " + test);
InputStream in = new ByteArrayInputStream(test.getBytes("UTF-8"));
ReportHandler handler = new ReportHandler();

saxParser.parse(in, handler);

Oas.DUMMY_ANSWER is a very long, pasted from Notepad.

It has also tested ByteArrayInputStream (test.getBytes ()) new; but no more chance.

If anyone can help?

My French is not a lot.

But I think that you do not get the exception when you replace the test with "" and ask yourself if it's limited to strings directly in the code?

I have a virtually identical to your code, data processing I was sent by a server.  It works very well.

But the SAXParseException does not indicate that you have an a problem XML with the string you pass in.  He'll tell you line and column number, which may be useful given that you printed the string beforehand.  It will also give you a message to tell you what the problem is.  If it is not, then if you have some kind of debugging in your manager, you will be able to understand the last bit of XML transformed.

To verify your XML file, your code is fine (certainly better than my French!).

Tags: BlackBerry Developers

Similar Questions

  • How to convert the string with numbers in the table of Boolean 2D

    Hello

    I have input a string with comma separated numbers 1,192 (starting at 1).

    This string must be converted to a table 2D-boolean. Each number that appears should be true, not true rest.

    The 2D table consists of 4 times of 0.47 Boolean values.

    1.48--> [0.47] numbers [0]
    49.96--> [0.47] numbers [1]
    Numbers 97.144--> [0.47] [2]
    145.192--> [0.47] numbers [3]

    If a '1, 49, 97 145' input string put all [0] [0.3] true.

    How can it be easy/fast resolved?

    Thanks for help

    Break the string of numbers in a table of numbers.  (Spreasheet String to Array).

    In a loop For, index with each issue of this table.  Use in the range and Coerce to see if it is in the range of numbers.  (You can put this in a loop For as auto good indexing through the ranges).  If it's in the range, then use subset replace table to activate the corresponding item in a real.  If this is not the case, do nothing.  Maintain the table of Boolean in a shift register.

    Repeat this step for each number in your table.

    (What is a class assignment?)

  • How to convert the string with numbers in U8 with ascii

    Hello

    I have a string with only numbers 0. 9 paper.

    Now, I want to convert to table-U8.

    He works here, but now the problem: How can I change each character to its ascii value?

    Example:

    entry: 123 (string)

    output: x 31, x 32, x 33 (U8-array)

    Thanks for the help

    It's very easy

    String to Byte Array Function
    Have the Palette: string/array/path Conversion functions

    Converts a string to an array of unsigned bytes. Each byte in the array has the ASCII value of the character corresponding to the string.

  • Number of strings with decimal

    Hello community,

    I would like to convert numbers to the string with decimal separators. So if the number is 52351 then the string I need is 52 351

    Another example 18653284.9653235 becomes 18,653,284.9653235

    What would be the best way to do it?

    Thank you!

    Read this thread: https://forums.ni.com/t5/LabVIEW/comma-separator-for-large-numbers-how-to/m-p/2123090/highlight/true...

    Not the first person to wish for this idea.

  • How to concatenate the string with a digital command?

    Hello

    How to concatenate the string with a digital command?

    Thank you.

    I think I forgot to add the semicolon, what you can do is, drag the CONCATENATE function and add semicolon.

  • How the filter string with don't cares...?

    Hello

    I need help on getting filter string with cares. Attached is a VI for ref.

    If anyone has chain, analysis of expertise; I need your help.

    Thank you

    SB_LV

    Another fun one

  • Initialization of a string with a UTF-8 character

    It doesn't seem like it should be that hard, but I am trying to initialize a string with a UTF-8 character (specifically a degree after a few numbers symbol).

    I tried:

    Dim myString As String = new String ("\uc2b0", "UTF - 8");

    as well as a few permutations but did not have luck...

    Java strings are in Unicode, UTF - 8 is a way to represent these characters in a stream of bytes.

    Take a look at the following code, it might be useful: I suggest to put point break in the line add and take a look at the content of the two strings.

    No compiled code, could not work, I hope you get the idea...

    Char [] testchars = new char [] {'\u00B0', '\u0020'};
    String displayString = "undefined";
    Byte [] testBytes = new byte [] {(byte) (byte), 0xC2 0xB0, 0x20};
    String displayString2 = "no set2";
    try {}
    displayString = new String (testchars);
    displayString2 = new String(testBytes,"UTF-8");
    } catch (Exception e) {}
    }
    BasicEditField bef = new BasicEditField ("Test2:", displayString + ":" + displayString2);
    This.Add (BEF);

  • How to concatenate strings with the lines of a text file

    Hello
    I tried concatenate strings with the lines of a text file, but something is wrong with my code and I belive is the agruments I use in the cycle for. If anyone can help me I will appreciate it very much.
    My code is:
    [code]@echo off
    the value "input=C:\Users\123\Desktop\List.txt".
    for /f "usebackq tokens = *" % in (' input % ') do)
    the value 'str1 = C:\some directory\ ".
    the value ' str2 = %% ~ F '.
    the value "str3 = .pdf".
    the value "str4 = str1% str2% str3%.
    echo.%STR4%
    ) [/ code]
    and the text file is something like:
    121122 [code]
    122233
    123344
    124455 [/ code]
    But I get only one wrong answer and I have to run it like 3 times to get a real result and it is a mistake, the first two are empty spaces and gives the third one as the last line of the text file but repeated n times, where n is the number of lines in the text file.
    Result:
    [code] C:\Users\123\Desktop>concatenate.bat
    C:\Users\123\Desktop>concatenate.bat
    C:\Users\123\Desktop>concatenate.bat
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\Users\123\Desktop>[/code]
    So if anyone has an idea about what is wrong please let me know.
    Concerning
    -Victor-

    Hi Victor,

    This forum is dedicated to the support of the Office of consumer Windows (fonts, colors, personal settings).  Since your question is about programming and usually outside the context of most of the customers, I suggest you post your question in the forums as http://msdn.microsoft.com - the Microsoft network to users will be more adapted to help you in your quest.
  • How to capture the data of type string with agent script and then compared to an alarm

    Hello...

    How to capture the string with agent of script data and then create a rule to compare the string data to generate alarm?

    Thank you!...

    Start here:

    http://en.community.Dell.com/TechCenter/performance-monitoring/Foglight-administrators/w/Admins-wiki/6155.custom-script-agent-1-leverage-an-existing-monitoring-script-to-push-data-into-Foglight

  • Search strings / with some applied condition

    Hello comrades,.

    I am writing an extendscript which is supposed to loop through all of the PGF and find all the strings / with a certain condition applied (say, comment).

    The problem is that in the script guide, I couldn't find a function that retrieves the status of character property. I tried to use the function "charAt() (i)" js, but it doesn't seem to work in ARE. No idea how to implement such a function?

    Here's the 1st draft of the script.

    var doc is app. ActiveDoc;

    If doc. {ObjectValid()}

    checkCondFMt (doc);

    }

    else {}

    Alert ("no open section");

    }

    function checkCondFMt (doc) {}

    FMP var is doc. MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

    var CondObj is doc. GetNamedObject ("Comment");

    While (FMP. {ObjectValid()})

    var textItems is bmp. GetText(Constants.FTI_String |) Constants.FTI_LineEnd);

    var b = new TextRange();

    TR. Beg.obj = tr.end.obj = textItems;

    TR. Beg.offset = 0;

    for (var i = 0; i < tr.len; i ++) {}

    var c = tr.charAt (i);

    var PgfProps is doc. GetTextVal c [i], Constants.FO_CondFmt;

    Alert (PgfProps.Name);

    }

    PGF = bmp. NextPgfInFlow;

    }

    }

    Thanks in advance for your comments!

    OK, I see the problem now. JavaScript doesn't have a "block scope" for its variables. She carried the function, so your 'i' variable is used in more than a loop. You must use a different variable for the inner loop:

    for (var j = 0; j < oCond.length; j += 1) {
        if (oCond[j].Name == CondObj.Name) {
            applyCharFmt(textRange, doc);
        }
    }
    

    In the code example above, I use 'j' for a counter for the inner loop.

    In general, you can avoid problems of this kind to declare all your variables at the top of the function:

    function functionName (param1, param2) {
    
        var i, j, textlist; // etc.
    
        // function code...
    }
    

    That makes it easier to 'follow' variables and make sure that you do not use one more than once.

    -Rick

  • dbms_random string with restrictions

    Hello. I want to generate a random string with certain restrictions. I need return numbers between 0-9 and letters from A - F. For those of you asking why the specific request, I need to create a string that is compatible with the unique identifier of the SQL SERVER. Jacky ideas how to add restrictions in the following lines.
    SELECT dbms_random.string('X', 32) AS Random_String
               INTO v_rand_string
               FROM dual;

    You have to use DBMS_RANDOM (which will inevitably generate duplicates)? If you try to be compatible with the unique identifier for SQL Server, why not use SYS_GUID, which is

    SELECT sys_guid()
      FROM dual
    

    Justin

  • Parsing XML in a string with kXML

    Hello

    I make a web service call that returns the XML in a string. I need to analyze this with kXML. The Setup is complete, but I can't find any help with regard to the analysis of the chain.

    Any help?

    Thank you

    Teja.

    Have you tried that?

     try{
                HttpConnection connection = null;
                InputStream inputStream = null;
    
                connection = (HttpConnection) Connector.open(URL + MainUI.connectionParameters,Connector.READ_WRITE, true);
                inputStream = connection.openInputStream();
    
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                Document document = builder.parse( inputStream );
    
                Element rootElement = document.getDocumentElement();
                rootElement.normalize();
                displayNode( rootElement, 0 );
            }
            catch ( Exception e )
            {
                System.out.println( e.toString() );
            }
    
    private void displayNode( Node node, int depth )
        {        
    
            if ( node.getNodeType() == Node.ELEMENT_NODE )
            {
                StringBuffer buffer = new StringBuffer();
                //indentStringBuffer( buffer, depth );
                NodeList childNodes = node.getChildNodes();
                int numChildren = childNodes.getLength();
                Node firstChild = childNodes.item( 0 );
    
                // If the node has only one child and that child is a Text node, then it's of
                // the form  Text, so print 'Element = "Text"'.
    
    if ( numChildren == 1 && firstChild.getNodeType() == Node.TEXT_NODE )
                {
    
                            buffer.append( firstChild.getNodeValue() );
                            buffer.append( "\n" );
                            add( new RichTextField( buffer.toString() ));
                            add( new SeparatorField());
    
                }
                else
                {
    
                    parentName = node.getNodeName();
    
                    for ( int i = 0; i < numChildren; ++i )
                    {
                        displayNode( childNodes.item( i ), depth + 1 );
                    }
                }
            }
            else
            {
    
                String nodeValue = node.getNodeValue();
                if ( nodeValue.trim().length() != 0 )
                {
                    StringBuffer buffer = new StringBuffer();
                    indentStringBuffer( buffer, depth );
                    buffer.append( '"' ).append( nodeValue ).append( '"' );
                    add( new RichTextField( buffer.toString() ));
                }
            }
        }
    
  • Converts a string with period in full

    Hello, I am easily able to convert the string "24233" in full, but I am unable to convert '2313.213123' in full why? How can I make the parser recognize the period as a decimal?

    Thank you

    Noah NAKED

    Hey noahnu,

    I tried to do what you said and it worked fine on my end. Here is the code that I tested with:

    var txt:String = "2313.213123";
    
    var num:int = parseInt(txt);
    
    trace(num); // traces 2313
    

    are you trying to keep the decimal value as well? If so, try rather using the number object:

    var txt:String = "2313.213123";
    
    var num:Number = Number(txt);
    
    trace(num); // traces 2313.213123
    

    hope that helps. Good luck!

  • using strings with percent sign

    I have a long text string that gets parsed as I create custom controls.  The question that I have is to have a percentage in this text string and flags sign is to jump.

    First of all, I doubled the percentage sign who took my first error an unknown specifier.  Now, I'm getting it again, but later in my code.

    String = "ringchoose 1 = Variable check 1-Var, Var 2 = 2, Var 3 = 3; ring: Variable Type compare-char = 1, = 2 int, float/double = 3, chain = 4; the value Format specifier: using %%d used if this value is returned in the string. See Help)-% v; ringoperation-less = 1, equal to = 2, Greater Than = 3, not equal to = 4; "value: value to compare.

    string_args = malloc(strlen(string_arguments)+1);                                  sprintf(string_args,string_arguments); //errored here first time                                        token = strtok(string_args,";");
    while (token != NULL) {                                           item_list=0;                                          arg_token = realloc(arg_token,strlen(token)+1);
                                                sprintf(arg_token,token);   //error here now
                                                            arg_ptr = strtok(arg_token,":");                                            if (strstr(arg_ptr,"ring") != NULL) {                                               arg_ptr = strtok(NULL,"-"); //should now hold title of ring                                             controlIDs[i] = NewCtrl(funcHandle,CTRL_RING,arg_ptr,50*(i+1)+offset,40);                                               SetCtrlAttribute(funcHandle,controlIDs[i],ATTR_WIDTH,200);
                                                    while (arg_ptr != NULL) {
                                                        arg_ptr = strtok(NULL,"=");
                                                        if ((arg_ptr == NULL) || (strchr(arg_ptr,';') != NULL)) break;
                                                        value = atoi(strtok(NULL,",\0")); //holds value
                                                InsertListItem(funcHandle,controlIDs[i],-1,arg_ptr,value);
                                                                    if (arg_ptr[0] == '*') {
                                                            GetNumListItems(funcHandle,controlIDs[i],&item_list);   //holds index-1 to set active
                                                        }
                                                    }
    }
    //Rest of if/elses not supplied  since I know looping works
    
    i++;
                                                sprintf(string_args,string_arguments);  //resets tokening
                                                token = strtok(string_args,";");
                                                for (int j = 0; j < i; j++) {
                                                    token = strtok(NULL,";");
                                                }
    

    It's almost as if the extra percentage signs stripped the first time and the second time I did of this chain, they mistake.

    In the example that you have posted, it seems that you could use strcpy() instead of the sprintf() function. strcpy() would not seek to interpret the content of the string in the same way.

    JR

  • String with \t\n output

    Hello

    I'm trying to add my string of the report output, and the output of the channel is something like this..."...\t\n, akfjdakjf\n, jaiejfiaje\n." When the string is displayed in the report, it displays everything in one line (made in one long line). I would like the report to show as below...

    ajkfj

    ajfkd jkjfka

    fjka

    Very grateful for the help. Thank you ~.

    Could you please show us how you write the text in the report?

    Please note that if it is a string variable that you pass on, "\n" is a string static and not evaluated with respect to escape characters. So if you want to have a new line, the variable itself must include the new line, is not the "\n'-"command"for a new line...

    Tip: If you need a new manual line, you can insert one pressing Ctrl + Enter...

    hope this helps,

    Norbert

Maybe you are looking for

  • Remove the line from the Excel report when generating reports

    Hi all I try to delete whole lines of the report excel during the generation of the report in excel, but I'm not able to do this. Here I am attaching an excel template, in that I want to delete line no 3 to 5 How can I do this. I'm using LabVIEW 8.6

  • Spare Lense

    Hey noob quick question guys, just a cannon powershot sx400 is. At just wonder if I had to get an adapter lens for her that could tie me up another lens?

  • Microsoft Update does not check the updates of VS2010 under XP SP3

    Updates of VS2010, or updates from Microsoft Update, can't find SP1 for VS2010, same if it should. This problem has been reproduced by Alexander Sun [MSFT] MSDN Community Support; its results can be found here http://social.msdn.microsoft.com/Forums/

  • ICONS ARE TOO BIG AFTER THE RECOVERY PROCESS

    MY SYSTEM CRASHED AND I MADE THE RECOVERY DISC, EVERYTHING WORKS WELL, LIKE A PC BRAND NEW, HOWEVER, MY ICONS WHEN I'M ONLINE, ARE HUGE, I CAN NOT THE LITTLE ONES, SO I'LL HAVE DIFFICULT TO READ EMAIL, MAIL, ETC.

  • HP f4210 Solution Center does not open

    I have tried to scan pictures and now cannot start the solution center to do this. I just uninstalled the program and reinstalled. When I try to start the program, nothing happens. No additional processes appear in the Task Manager. I rebooted the co