Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107419 > unrolled thread
| Started by | Joaquin Alzola <Joaquin.Alzola@lebara.com> |
|---|---|
| First post | 2016-04-20 09:28 +0000 |
| Last post | 2016-04-20 21:43 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Xlms namespace Joaquin Alzola <Joaquin.Alzola@lebara.com> - 2016-04-20 09:28 +0000
Re: Xlms namespace sohcahtoa82@gmail.com - 2016-04-20 10:52 -0700
RE: Xlms namespace Joaquin Alzola <Joaquin.Alzola@lebara.com> - 2016-04-20 21:43 +0000
| From | Joaquin Alzola <Joaquin.Alzola@lebara.com> |
|---|---|
| Date | 2016-04-20 09:28 +0000 |
| Subject | Xlms namespace |
| Message-ID | <mailman.35.1461171872.12923.python-list@python.org> |
Hi Guys
I am currently doing this:
IP client(Python) --> send SOAPXML request --> IP Server (Python)
SOAP request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http:/
/request.messagepush.interfaces.comviva.com" xmlns:xsd="http://request.messagepush.interfaces
.comviva.com/xsd">
<xsd:text>test\ntest\ntest<{[£€&%]}></xsd:text>
From my IP Client:
s.send(data_send.encode('utf-8'))
From my IPServer:
xml_decoded = data.decode('utf-8')
xml_root = ET.ElementTree(ET.fromstring(xml_decoded)).getroot()
for elem in xml_root.getiterator():
if('{http://request.messagepush.interfaces.comviva.com/xsd}shortCode'==elem.tag):
shortCode = (elem.text).rstrip()
if('{http://request.messagepush.interfaces.comviva.com/xsd}text'==elem.tag):
send_text = (elem.text).rstrip()
if('{http://request.messagepush.interfaces.comviva.com/xsd}item'==elem.tag):
subscribers = (elem.text).rstrip()
result_sms = send_sms(subscribers,shortCode,send_text)
It is working fine but I am having problems with a couple of special characters, & and <
The problem:
<xsd:text>test\ntest\ntest<{[£€&%]}></xsd:text>
It seems as if I send this: <> and the character & then I have a problem.
I need to use utf-8 as I need to make sure I get 160 characters in one SMS.
Error:
Traceback (most recent call last):
File "./ipserver.py", line 52, in <module>
main()
File "./ipserver.py", line 36, in main
xml_root = ET.ElementTree(ET.fromstring(xml_decoded)).getroot()
File "/usr/lib64/python3.4/xml/etree/ElementTree.py", line 1325, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 19, column 48
This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.
[toc] | [next] | [standalone]
| From | sohcahtoa82@gmail.com |
|---|---|
| Date | 2016-04-20 10:52 -0700 |
| Message-ID | <c098c5b6-0091-448f-8538-5f1bcdf32f9a@googlegroups.com> |
| In reply to | #107419 |
On Wednesday, April 20, 2016 at 10:05:02 AM UTC-7, Joaquin Alzola wrote:
> Hi Guys
>
> I am currently doing this:
>
> IP client(Python) --> send SOAPXML request --> IP Server (Python)
>
> SOAP request:
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http:/
> /request.messagepush.interfaces.comviva.com" xmlns:xsd="http://request.messagepush.interfaces
> .comviva.com/xsd">
> <xsd:text>test\ntest\ntest<{[£ EURO&%]}></xsd:text>
>
> From my IP Client:
> s.send(data_send.encode('utf-8'))
>
> From my IPServer:
> xml_decoded = data.decode('utf-8')
> xml_root = ET.ElementTree(ET.fromstring(xml_decoded)).getroot()
> for elem in xml_root.getiterator():
> if('{http://request.messagepush.interfaces.comviva.com/xsd}shortCode'==elem.tag):
> shortCode = (elem.text).rstrip()
> if('{http://request.messagepush.interfaces.comviva.com/xsd}text'==elem.tag):
> send_text = (elem.text).rstrip()
> if('{http://request.messagepush.interfaces.comviva.com/xsd}item'==elem.tag):
> subscribers = (elem.text).rstrip()
> result_sms = send_sms(subscribers,shortCode,send_text)
>
> It is working fine but I am having problems with a couple of special characters, & and <
>
> The problem:
> <xsd:text>test\ntest\ntest<{[£ EURO&%]}></xsd:text>
>
> It seems as if I send this: <> and the character & then I have a problem.
> I need to use utf-8 as I need to make sure I get 160 characters in one SMS.
>
> Error:
> Traceback (most recent call last):
> File "./ipserver.py", line 52, in <module>
> main()
> File "./ipserver.py", line 36, in main
> xml_root = ET.ElementTree(ET.fromstring(xml_decoded)).getroot()
> File "/usr/lib64/python3.4/xml/etree/ElementTree.py", line 1325, in XML
> parser.feed(text)
> xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 19, column 48
> This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.
If I had to make a guess, you need to escape the <, >, and &characters or else they'll get parsed by the XML parser. Try sending "<xsd:text>test\ntest\ntest<{[£ EURO&%]}></xsd:text>"
[toc] | [prev] | [next] | [standalone]
| From | Joaquin Alzola <Joaquin.Alzola@lebara.com> |
|---|---|
| Date | 2016-04-20 21:43 +0000 |
| Message-ID | <mailman.42.1461201363.12923.python-list@python.org> |
| In reply to | #107420 |
>> The problem:
>> <xsd:text>test\ntest\ntest<{[£ EURO&%]}></xsd:text>
>If I had to make a guess, you need to escape the <, >, and &characters or else they'll get parsed by the XML parser. Try sending "<xsd:text>test\ntest\ntest<{[£ EURO&%>]}></xsd:text>"
Yes it is the xml itself.
Putting the & and also the < I can make it work with the desire characters
So the result: test\ntest\ntest<{[£&€%]}>
Will print < and also &.
Thanks.
This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web