Can't parse "bad" characters - need help

Hey everyone, this should be simple. I am trying to parse (DOM parser) and XML string that has some funky characters in it. I am getting the following error:
Illegal XML character: & # x 1 d ; (had to use spaces so that it would print out properly...otherwise: 
I have a findAndReplace method that I can use to replace the bad characters with their proper values (copy paste from Word to notepad of single quotes really screws things up), but I can't seem to get it to work. What should I pass in to be replaced? I know that this is a hexadecimal for '29', but I can't seem to get my findAndReplace to work by passing in &#x1d, & # x 1 d ;, or java.lang.String.valueOf(29). Please help, thanks!
FYI...here's my findAndReplace method.
public static String findAndReplace(String original, String replaceThis, String withThis) {
if (original==null || replaceThis==null || withThis==null) {
return null;
int i = original.indexOf(replaceThis);
if (i == -1) {
return original;
int replaceThisSize = replaceThis.length();
int withThisSize = withThis.length();
while (i != -1) {
String beforeString = original.substring(0, i);
String afterString = original.substring(i + replaceThisSize);
original = beforeString + withThis + afterString;
i = original.indexOf(replaceThis, i + withThisSize);
return original;

warnerja, you're right. That character should not be
there. However, I can not guarantee that it will not
be there as it comes from a different system and
people are pasting Word docs into this system all the
time. You can train people all you want, but they
don't always listen. So, I need to make sure my code
doesn't blow up when the do do this. Hence my issue.I'd follow the GIGO (garbage in, garbage out) principle. Are you also going to need to code it to read their minds when they provide no sensible input whatsoever, like:
<hey, figure this>junk<out/>man</hey, figure this>

Similar Messages

  • Workflow XML R/3 can't parse XML answer, need help for syntax

    Hello all,
    i got a serious problem with workflow XML. I's a lot of text.
    What do we do:
    In worflow for PR's, there is a web activity, that sends out informations to a domino server. Sending out and receiving the acknowledgement works. The web activity than waits, until a answer comes in.
    Now, if the domino user releases or rejects the PR, domino sends a XML message to R/3. This message is the big problem!!
    R/3 documentation is not clear in this case. The R/3 example shows this syntax
    <?xml version="1.0" ?>
    <WfMessage Version="SAP.1.0">
    <WfMessageHeader>
      <Request>
       <ResponseRequired>Yes</ResponseRequired>
      </Request>
        <Key>http://www.xyz.com/SAP/BC/WORKFLOW_XML/?protocol=01&localkey=000000111669</Key>
        <Operation>ProcessInstanceStateChanged</Operation>
    </WfMessageHeader>
    <WfMessageBody>
      <ProcessInstanceStateChanged>
        <Key>http://www.xyz.com/SAP/BC/WORKFLOW_XML/?protocol=01&localkey=000000111669</Key>
        <ProcessInstanceKey>http://www.xyz.com/SAP/BC/WORKFLOW_XML/?protocol=01&localkey=000000112625</ProcessInstanceKey>
       <State>closed.completed</State>
       <ResultData>
         <ANSWER>test successful</ANSWER>
       </ResultData>
      </ProcessInstanceStateChanged>
    </WfMessageBody>
    </WfMessage>
    Link to the example:
    http://help.sap.com/saphelp_47x200/helpdata/de/54/de9e3887d6174fe10000009b38f842/frameset.htm
    In that case, the "key" tag points to the external system, but has an "localkey" parameter, that holds the R/3 instance of the workflow task. "ProcessInstanceKey" seems to be the key for the external system. Completely confusing!!
    Whenever we build our XML message in that way, we got the error 104 which means, that a process state change from [blank] to [blank] is not foreseen.
    Can anybody help further?
    Is there any document, that describes clear, how to build up such answer messages in WF XML?
    Thanks in advance for the answers!!
    Cheers
    Jens

    Hi Martin,
    thank you for your reply!
    Unfortunately, there is no way, to generate the incoming answer, because it comes from a domino server, who has implemented it through raw coding&MS XML. The only way to generate would be, to implement a workflow call from
    Domino to R/3, but i think in this case, it will consume to much time and R/3 documentation seems to be definitely wrong.
    Just have a look: abc.com is the WF-Initiator, xyz.com the consumer, localkey from abc.com is a part of xyz.com and the target in that case must be abc.com with this localkey.
    I studied the Wf-XML specification and, allthough it uses a different dialect (1.1), it seems to be, that the Key-Tag and ProcessInstanceKey-Tag are wrong in R/3 documentation. The error codes thrown in our implementation are 104 in the XML response and 200 in HTTP response, so this indicates a wrong key-value.
    We just want to implement a short test scenario, to proof our thing working, but my customer and the Domino developer are houndreds of miles away and time becomes very short from all sides. Every change on side of Domino seems to be a very complicated task and the developer wants a exact example of how to implement the interface, which i can't deliver ad hoc. Trial&error is a very bad idea in this case..
    OSS call is opened now, hope, they respond quickly, because i only can set the call to middle priority, no production - but development stop.
    Cheers
    Jens

  • HT1386 my Ipod will not connect to my computer it worked yesterday but not today and it is only a new ipod touch, it will not even be recognised on my itunes but yet it can charge off my computer. need help!

    it worked yesterday but not today and it is only a new ipod touch, it will not even be recognised on my itunes but yet it can charge off my computer. need help!

    iOS: Device not recognized in iTunes for Mac OS X
    or
    iOS: Device not recognized in iTunes for Windows

  • I need help! I updated the new 6.1.3 last night. Since that time my phone will not charge. The phone is plugged in and shows as charging but the battery still drains. What can I do? I need help!

    I need help! I updated the new 6.1.3 last night. Since that time my phone will not charge. The phone is plugged in and shows as charging but the battery still drains. What can I do? I need help!

    Restore iPhone with iTunes on your computer.

  • HT1937 I have an iphone bought in the UK but I'm in Europe and can not use it I need help please help me thanks

    I have an iphone bought in the UK but I'm in Europe and can not use it I need help please help me thanks

    wiliiam rrichard wrote:
    Because My iphone is Locked on the United Kingdom
    No it is not.  iPhones, like all cell phones are not locked to countries.  They are locked to carriers.
    Only the carrier to whom the device is locked can unlock it.  Contact the carrier.

  • All of my photos are displayed as BW because somehow I've saved a quick develop preset and it saves as BW.  This is for all of my photos.  I can individually undo them but need help in how to get rid of the preset so it goes to Default. thanks

    All of my photos are displayed as BW because somehow I've saved a quick develop preset and it saves as BW.  This is for all of my photos.  I can individually undo them but need help in how to get rid of the preset so all photos goes to Default or as shot. thanks

    Go to the develop module and highlight all of the images in the filmstrip at the bottom of the screen. Then activate Auto-sync and click on the Reset button. That should reset all of the images to your camera default settings.

  • My Mac is lagging big and whenever I click on something it just goes to the spinning wheel of death I can't do anything I need help

    Somebody help me My Mac is lagging big and whenever I click on something it just goes to the spinning wheel of death I can't do anything I need help

    What model year Mac and what version of OS X are you running.
    If this is on an older Mac with standard Rotating HDD it could be a sign the HDD is either to full of data or it is starting to fail. It could also be caused by 3rd party software you've installed.

  • I wanted to erase my file,cause I hv about 65 G in my user disk, but I can't open my file. need help

    I wanted to erase my file,cause I hv about 65 G in my user disk, but I can't open my file. need help

    The advice you've received previously seems pretty solid, so let's troubleshoot the problem.
    evefromOz wrote:
    PLease help tech unsavvy struggler. After a grey screen and damaged HD that will not repair I was advised to copy my HD and Leopard installation to a new drive, then erase the HD and reinstall. But now can't open anything as my password wont work anymore.
    Let's concentrate on this portion of text only.
    Gray screen: usually means non-woriking or uninstalled HD
    Won't repair: makes perfect sense, since you no longer have access to HD
    Advised to copy HD and Leopard installation to a new drive, then erase the HD and reinstall: This is the most important text. It seems you don't use a backup drive. And since your HD is damaged/not working, you need to do the following: (1) remove the faulty drive, (2) install the new drive, (3) when you turn on your MBP, you may need to erase the newly installed HD, and this is where you have the problems. Describe, in detail, what's happening on your MBP screen. Is it still gray? What message are you getting? Where is it asking you for a password, and when?
    I'm intereste: since your MBP drive is dead, how are you accessing this forum?

  • How can this pattern work? need help!!

    the model i need have 3layers:JSP+EJB+SocketServer, i know EJB can act as Socket Client(not Server),but the
    main problem is that i must use a .dll or .lib file(written in
    c) in EJB to packge the socket data.someone says EJB
    can use JNI while EJB Spec won't allow it, i dont't want
    to take the risk also.Is there any other way can work?
    (use runtime in EJB?)
    if EJB can't work in this pattern,can i have another choice? (JSP and SocketServer can't be replaced)
    NEED HELP!

    Use the Mediator pattern.

  • My IPhone 4 has been jail broken and I can't restore it I need help

    I Need Help Restoring My Jailbroken iPhone 4

    More on jailbreaking:
    http://sites.google.com/site/appleclubfhs/support/advice-and-articles/what-is-ja ilbreaking
    Note that my links to other pages may take you to my organization's page and should not be taken as an endorsement from Apple.

  • You must authorize this computer before you can download previous purchases. Need help for MacBook Pro

    Need help to authorize my computer

    Open iTunes
    From the Store menu, choose Authorize This Computer. (In earlier versions of iTunes, access this option from the Advanced menu).
    When prompted, enter your Apple ID and password, then click Authorize.
    http://support.apple.com/kb/HT1420?viewlocale=en_US&locale=en_US

  • SAX error parsing by element. need help!

    I am trying to develop a small method to that can parse an xml file and return an elements value. I got some code to build a SAXHandler. I have build the SAXHandler and have compiled it no problem.
    import java.io.*;
    import java.util.Hashtable;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    public class SAXHandler extends DefaultHandler {
    private Hashtable table = new Hashtable();
    private String currentElement = null;
    private String currentValue = null;
    public void setTable(Hashtable table) {
    this.table = table;
    public Hashtable getTable(){
    return table;
    public void startElement(String tag, Attributes attrs)
    throws SAXException {
    currentElement = tag;
    public void characters(char[] ch, int start, int length)
    throws SAXException {
    currentValue = new String(ch, start, length);
    public void endElement(String name) throws SAXException {
    if (currentElement.equals(name)) {
    table.put(currentElement, currentValue);
    I am using the following code to read the file in and parse it.
    public String getXMLElement(){
    try {
    File xmlFile = new File(appDataFile);
    FileReader xmlRead = new FileReader(xmlFile);
    XMLReader xmlParser;
    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser sp = spf.newSAXParser();
    SAXHandler handler = new SAXHandler();
    sp.parse(new InputSource(xmlRead), handler);
    i am recieving the following error when I try to run the servlet
    javax.servlet.ServletException: Cannot allocate servlet instance for path /JDtrack/servlet/JDTrack
    what makes this wierd is that is i take out the line
    sp.parse(new InputSource(xmlRead), handler);
    I do not get the error.
    I am newer to java and could use all the help I can get
    thanks.

    A few things to try to help identify the problem:
    -Create and InputSource before parsing the file. If the InputSource cannot be created, there may be a problem with accessing the file from your servlet.
    -Write a quick program to do the same thing from an application. If you can do this outside the servlet container, it may be a problem from running inside the servlet container.
    -The code you listed is in a try block, however the catch block is not listed. If you are not already doing so, place debug message (to console or log) from inside each catch block. If an exception is thrown but not handled corrrectly, the servlet container may just throw a ServletException.
    Hope this helps.

  • Bad ipod need help badly!!!

    So my 20gb photo was working fine then all of a sudden it gave me thesad ipod. Then i tried everything possible to fix it and it didnt work. Then all of a sudden it kept asking for it to be plugged into a wall charger. So i plugged it in to one and it would then go the chargeing bar and freeze. is there ne way to fix this without having to basically buy a new ipod. PLZ HELP!!!.
    Dell   Windows Vista   20 gb ipod photo

    You can't.. it is terrible..
    the only app that really uses it is mirror
    Open this link on your phone to install mirror
    http://maemo.org/downloads/product/raw/Maemo5/mirror?get_installfile
    the camera firmware is bad, so the image quality is truely terrible.. play with mirror to see.. it may be fixed in a future firmware release (it *IS* better than it was.. the firmware last year had a line through the picture!)

  • HT2368 Hello, I have MacBook Late 2008 (Unibody). And I can't install this firmware, need help. Thanks

    Hello,
    I have MacBook Late 2008 (Unibody). And I can't install this firmware MacBook SMC Firmware Update 1.5
    Need your help.
    Thanks

    Also, according the the 1.4 update page here: http://support.apple.com/kb/DL974
    It will update the Boot ROM version (on MB 5,1) to MB51.007D.003.
    Yet I have (MB 5,1) Boot ROM version MB51.007D.B03. Weird again!
    What a mess Apple. Considering how important firmware updates are you'd think they could make this a little clearer.
    Anyways, again, I don't think we need it.

  • Reset router, can't connect to net - need help

    Here's my situation, I spent an hour digging through previous posts trying to solve my issue with no luck.
    Had Cavtel DSL running to a Linksys wrt54g ver.2 router which was working fine.  My brother needed access to the network but we forgot the password which was set about 2 years before. 
    I hit the reset button on the back of the linksys router and promptly lost access to the internet from my computer.
    I contacted linksys help over the phone and after dealing with someone in India he told me that they would charge me to walk me through it.  I disconnected and tried cavtel... They told me to plug the cavtel modem directly to the pc.  I still couldn't access the internet at this point.
    She then had me modify my tcp/ip settings and gave me nifty numbers that allowed me to get back online.  I asked her about the router and she said, oh just plug the modem into it and it will self detect everything and emphasized that I should call linksys and they'll be GLAD to help me out...
    Needless to say, I plugged the internet into the router and once again can't get online.  I then tried to backtrack and plug the pc back directly to the modem and can't connect to the internet once more.  Contacted cavtel and their response was the classic, well we got you working directly we can't help you with router issues.
    I don't have the install cd anymore, and I haven't a clue what to do to fix this.  Top this off, there are no other wireless networks around my house so I can't access this forum from home or any online 'easy help' tools or programs.
    Anyone have any suggestions???  And yes I know the basics of accessing the modem, the 192.168.1.1 etc etc admin password. 
    Thanks for help in advance.
    Message Edited by seawolf688 on 06-11-2008 09:00 AM

    Configuration for DSL connection:-
    Before doing the following steps, you have to connect the modem to the
    router's Internet Port and the computer to the Ethernet Port Number 1.
    1. Press and hold the reset button for 30 seconds.
    2. Then, unplug the power keep holding down the reset button for
    another 30 Seconds.
    3. Plug back the power back in, and keep holding down the reset button
    for 30 Seconds.
    4. Release the reset button.
    ===================================================================
    Access the setup page of the router by launching an
    Browser and type on the address bar, 192.168.1.1 and press enter. When
    it prompts for the username and password, leave the username field
    empty and provide password as "admin" (Without quotes)
    click on ok.
    On the main setup page the ""Internet Connection Type"" should be
    on ""Obtain IP Automatically - DHCP ?. Click on the Save Settings
    button.
    Now click on the sub tab ""MAC address clone"".
    - Click on enable
    Click Clone & click save settings
    Check WAN Ip on Status page of router ....
    If getting Valid Ip .... try going online
    If not ... power cycle for 4-5 minutes & then agian check the WAN Ip address .....

Maybe you are looking for

  • How can I embed a Keynote presentation on a web page?

    I created a Keynote presentation using Keynote version 6.5 (OS X Yosemite). I found the "export as html" option, which creates an entire web page named index.html. I opened that web page in Dreamweaver, but I'm not talented enough to figure out how t

  • How to supress value '#' in variable selection screen?

    Hi gurus, i wonder if there is any solution for this question: Before query execution, when system requests variable values, in the list of available values for filtering 0calyear, allways apears value '#' and the rest of values loaded in the infocub

  • Receiver File adapter encoding

    Hi All , My scenario is ABAP Proxy --> XI -->Flat file. My receiver is flat file , comma separated to a NFS.... there is a character ß in one of the fields of source payload. When I am using UTF-8 in the receiver channel , this character is displayed

  • VO substitution not taking effect when running from Jdev

    Hi, I made a VO substition. However, when running the page from Jdev, the substition is not in effect. When I press "about this page" I see the original view objects - not my own. I have verified that my .jpx file contains the substitution. I have tr

  • Sending contacts from iphone via blue tooth

    Is it possible to do this? Please help?