Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7524835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:10:03+00:00 2026-05-30T03:10:03+00:00

I have a pretty simple bit of javascript that attempt to parse the xml

  • 0

I have a pretty simple bit of javascript that attempt to parse the xml I’ve extracted from the metadata in a jpeg:

var xmlDoc;
try {
    xmlDoc = $.parseXML(xmlString);
} catch(e) {
    console.log(e);
}

Here is the exception that gets thrown:

Invalid XML: <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
         <photoshop:Instructions>C1DDZVs9Sr+DG5R9eSc%9w</photoshop:Instructions>
      </rdf:Description>
      <rdf:Description rdf:about=""
            xmlns:aux="http://ns.adobe.com/exif/1.0/aux/">
         <aux:SerialNumber>1</aux:SerialNumber>
         <aux:Lens>AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED [II]</aux:Lens>
         <aux:LensID>1</aux:LensID>
         <aux:ImageNumber>6651</aux:ImageNumber>
         <aux:FlashCompensation>0/1</aux:FlashCompensation>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>

There doesn’t seem to be anything wrong with that XML. In fact, if I cut and paste that xml in directly, no exception is thrown:

var xmlDoc;
try {
    xmlDoc = $.parseXML('<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0">       <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">          <rdf:Description rdf:about=""                xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">             <photoshop:Instructions>C1DDZVs9Sr+DG5R9eSc%9w</photoshop:Instructions>          </rdf:Description>          <rdf:Description rdf:about=""                xmlns:aux="http://ns.adobe.com/exif/1.0/aux/">             <aux:SerialNumber>1</aux:SerialNumber>             <aux:Lens>AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED [II]</aux:Lens>             <aux:LensID>1</aux:LensID>             <aux:ImageNumber>6651</aux:ImageNumber>             <aux:FlashCompensation>0/1</aux:FlashCompensation>          </rdf:Description>       </rdf:RDF>    </x:xmpmeta>' );
} catch(e) {
    console.log("error parsing xml: " + e);
}

I can only assume that there must be some kind of unprintable special character in there somewhere that is causing the trouble. How can I test that assumption and fix it, or perhaps something else is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:10:06+00:00Added an answer on May 30, 2026 at 3:10 am

    I’ve found the problem. As I suspected, there was some nasty unprintable character lurking at the end of the string.

    I was able to remove it with this dirty bit of hacking:

    xmlString = xmlString.substr(xmlString.indexOf("<"), xmlString.lastIndexOf(">") + 1);
    

    If it’s not obvious, it simply trims away anything from the start and end of the string that isn’t the expected angle brackets of an xml document. The jQuery function “trim()” was not effective at removing the rogue character as that only does whitespace.

    I don’t know what the character was, and I’m not particularly happy with my solution, but I’m too busy to spend more time on it. Sigh.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple Linq to XML query: var q = from c
I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a pretty simple problem. Basically I have an array called $list that
I have added a simple .js file to my page that has some pretty
I have a pretty simple C program that does some cryptographic calculations using only
I have a pretty simple window that contains an NSTextView. I'm calling readRTFDFromFile: to
i have pretty simple simple question (i hope so). How do i change the
I have a pretty simple SQL I need to perform. I have a ProcessUser
I have a pretty simple question which perhaps someone familiar with Server/Client design &
I have a pretty simple case which I started solving using foreach(), but then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.