XML encoding.

21 views
Skip to first unread message

Phil

unread,
Feb 16, 2009, 12:31:49 PM2/16/09
to AdWords API Forum
I am not sure how to approach this problem. I am currently working in
the sandbox.
I am using the .net adwords API library (v12 or v13 - at the time of
writing I am not sure). I am XML encoding all values before I send
them to a service. However I am still getting 'There is an error in
XML document(16,32)' errors.
I always get this error on some kind of special character (though not
always one I would expect to need to encode) but it doesn't seem to
happen consistently.

It always seems to happen when I am checking critera and doesn't
happen in my code (it is in the serialisation in the criterion service
call). It appears to happen when the serialisation is trying to parse
an int.

Has anyone else had this kind of error?
Should I be XML encoding things or relying on the API library to do
that for me?
How would I 'see' the XML that is being sent?

Cheers
Phil.

Phil

unread,
Feb 16, 2009, 12:42:55 PM2/16/09
to AdWords API Forum
PS, I have just noticed.....
I am getting this problem with '(' not only special characters.

AdWords API Advisor

unread,
Feb 17, 2009, 11:29:59 AM2/17/09
to AdWords API Forum
Hello Phil,

Yes, the error you describe is coming from Microsoft's XML
serialization library code. You say that it happens when serializing
integers--what makes you think that? Any how is it that you're passing
in anything other than the characters 0-9 for an integer value?

I'd think that if you break into the debugger when this exception is
through there should be some way to get more information about the
error from inspecting the exception's properties--Visual Studio's
debugger is usually pretty good about that. Unfortunately, if this
error is occurring during XML serialization as you suggest, it's
unlikely that you would be able to turn on logging to see the XML
being generated, as it's the XML generation itself that is failing.

Cheers,
-Jeff Posnick, AdWords API Team

Phil

unread,
Feb 17, 2009, 11:37:12 AM2/17/09
to AdWords API Forum
Hi Jeff.
The parse int thingy was the only error I was digging up. It turns out
to have been a red herring.

I did some further investigation and it appeared that
A. I don't need to encode for XML it is handled by the .net xml
object.
B. The problem wasn't XML encoding it was other special characters and
length that was being thrown as XML errors.

I found an error (turning on logging) telling be that ( and ) and ,
were illegal - so I got rid of them. Then I found that @ was illegal.
Also I found that some of the errors are to do with the length of
criterion. I think I have found most of the illegal things now. I
couldn't find an illegal character list and haven't dug around for a
style sheet.

Cheers
Phil
On Feb 17, 4:29 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
wrote:

AdWords API Advisor

unread,
Feb 17, 2009, 12:03:28 PM2/17/09
to AdWords API Forum
Hello Phil,

Are you saying that the AdWords SOAP service returns a fault back
complaining that your ad or keyword has illegal characters in it? The
policies in place for checking ads submitted via the API are the same
as those for ads submitted using the AdWords web interface. There are
a couple of AdWords help center articles about characters that can and
cannot appear in various AdWords objects:

http://adwords.google.com/support/bin/answer.py?hl=en&answer=6313
http://adwords.google.com/support/bin/answer.py?hl=en&answer=57787

Cheers,
-Jeff Posnick, AdWords API Team


Phil

unread,
Feb 17, 2009, 12:44:46 PM2/17/09
to AdWords API Forum
Great. Thank you.
However, these errors are coming back as XML errors before the query
is sent.
It doesn't seem to like (,)@% in the text of a keyword phrase.

On Feb 17, 5:03 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
Reply all
Reply to author
Forward
0 new messages