The advances in multimedia and networking technologies have created opportunities for Internet pirates, who can copy digital contents and illegally distribute them, thus violating the legal rights of content owners. In such a situation, digital watermarking has gained popularity as a main technology to implement the copyright protection of multimedia digital contents distributed on the Internet. We present a novel "nonblind" watermarking procedure for JPEG images based on the use of protected extensible markup language (XML) documents. The procedure enables the copyright owner to insert a distinct watermark code identifying the buyer into the distributed images. Furthermore, to increase the security and robustness levels of the procedure, the watermark is repeatedly embedded into an image in the discrete cosine transform (DCT) domain at different frequencies and by exploiting both block classification techniques and perceptual analysis. The embedded watermark is then extracted from an image according to the information contained in a protected XML document that is associated to the image.