Search Results

Search found 10 results on 1 pages for 'xmlparsing'.

Page 1/1 | 1 

  • : in node causing Keyerror in xmlparsing using ElementTree

    - by kguckian
    Hi I'm using ElementTree to parse out an xml feed from Kuler. I'm only beginning in python but am stuck here. The parsing works fine until I attempt to retrieve any nodes containing ':' e.g kuler:swatchHexColor Below is a cut down version of the full feed but same structure: <rss xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:kuler="http://kuler.adobe.com/kuler/API/rss/" xmlns:rss="http://blogs.law.harvard.edu/tech/rss" version="2.0"> <channel> <title>kuler popular themes</title> <item> <title>Theme Title: Fresh Money</title> <description> &lt;img src="http://kuler-api.adobe.com/kuler/themeImages/theme_808366.png" /&gt;&lt;br /&gt; Artist: thesylph005&lt;br /&gt; ThemeID: 808366&lt;br /&gt; Posted: 03/02/2010&lt;br /&gt; Hex: 2F400D, 8CBF26, A8CA65, E8E5B0, 419184 </description> <kuler:themeItem> <kuler:themeID>808366</kuler:themeID> <kuler:themeTitle>Fresh Money</kuler:themeTitle> <kuler:themeImage>http://kuler-api.adobe.com/kuler/themeImages/theme_808366.png</kuler:themeImage> <kuler:themeAuthor> <kuler:authorID>370750</kuler:authorID> <kuler:authorLabel>thesylph005</kuler:authorLabel> </kuler:themeAuthor> <kuler:themeTags/> <kuler:themeRating>4</kuler:themeRating> <kuler:themeDownloadCount>708</kuler:themeDownloadCount> <kuler:themeCreatedAt>20100302</kuler:themeCreatedAt> <kuler:themeEditedAt>20100302</kuler:themeEditedAt> <kuler:themeSwatches> <kuler:swatch> <kuler:swatchHexColor>2F400D</kuler:swatchHexColor> <kuler:swatchColorMode>rgb</kuler:swatchColorMode> <kuler:swatchChannel1>0.183333</kuler:swatchChannel1> <kuler:swatchChannel2>0.25</kuler:swatchChannel2> <kuler:swatchChannel3>0.05</kuler:swatchChannel3> <kuler:swatchChannel4>0.0</kuler:swatchChannel4> <kuler:swatchIndex>0</kuler:swatchIndex> </kuler:swatch> <kuler:swatch> <kuler:swatchHexColor>8CBF26</kuler:swatchHexColor> <kuler:swatchColorMode>rgb</kuler:swatchColorMode> <kuler:swatchChannel1>0.55</kuler:swatchChannel1> <kuler:swatchChannel2>0.75</kuler:swatchChannel2> <kuler:swatchChannel3>0.15</kuler:swatchChannel3> <kuler:swatchChannel4>0.0</kuler:swatchChannel4> <kuler:swatchIndex>1</kuler:swatchIndex> </kuler:swatch> <kuler:swatch> <kuler:swatchHexColor>A8CA65</kuler:swatchHexColor> <kuler:swatchColorMode>rgb</kuler:swatchColorMode> <kuler:swatchChannel1>0.659722</kuler:swatchChannel1> <kuler:swatchChannel2>0.791667</kuler:swatchChannel2> <kuler:swatchChannel3>0.395833</kuler:swatchChannel3> <kuler:swatchChannel4>0.0</kuler:swatchChannel4> <kuler:swatchIndex>2</kuler:swatchIndex> </kuler:swatch> <kuler:swatch> <kuler:swatchHexColor>E8E5B0</kuler:swatchHexColor> <kuler:swatchColorMode>rgb</kuler:swatchColorMode> <kuler:swatchChannel1>0.91</kuler:swatchChannel1> <kuler:swatchChannel2>0.898047</kuler:swatchChannel2> <kuler:swatchChannel3>0.688705</kuler:swatchChannel3> <kuler:swatchChannel4>0.0</kuler:swatchChannel4> <kuler:swatchIndex>3</kuler:swatchIndex> </kuler:swatch> <kuler:swatch> <kuler:swatchHexColor>419184</kuler:swatchHexColor> <kuler:swatchColorMode>rgb</kuler:swatchColorMode> <kuler:swatchChannel1>0.254901</kuler:swatchChannel1> <kuler:swatchChannel2>0.57</kuler:swatchChannel2> <kuler:swatchChannel3>0.519034</kuler:swatchChannel3> <kuler:swatchChannel4>0.0</kuler:swatchChannel4> <kuler:swatchIndex>4</kuler:swatchIndex> </kuler:swatch> </kuler:themeSwatches> Tue, 30 Mar 2010 11:27:12 PST So if I do a findall on say each item's description, I get that back fine. But the minute I try to retrieve anything with a : in the nodename I get Exception Type: KeyError Exception Value: ':' So this works from elementtree.ElementTree import Element, SubElement, dump, parse def xml(): kulerurl = 'http://kuler-api.adobe.com/rss/get.cfm?listType=popular&startIndex=0&itemsPerPage=5&timeSpan=30&key=mykey' rss = parse(urllib.urlopen(kulerurl)).getroot() for element in rss.findall('channel/item'): print(element.findtext('description')) dump (rss) but this doesn't def xml(): kulerurl = 'http://kuler-api.adobe.com/rss/get.cfm?listType=popular&startIndex=0&itemsPerPage=5&timeSpan=30&key=mykey' rss = parse(urllib.urlopen(kulerurl)).getroot() for element in rss.findall('channel/item/kuler:themeItem'): print(element.findtext('kuler:themeID')) dump (rss) I'm sure it's something simple if anyone could point me to what I'm doing wrong here I'd be most grateful thanks Kieran

    Read the article

  • Ruby XMLParsing Exception

    - by Rajesh
    I get a ParseException every time I try to parse a http get_response data in Ruby. The Exception is because of the presence of '&' in the data. How do I solve this? Illegal character '&' in raw string (REXML::ParseException)

    Read the article

  • Something wrong with my XML?

    - by Prateek Raj
    hi everyone, i'm parsing an xml with my extjs but it returns only one of the five components. only the first one of the five components. Ext.regModel('Card', { fields: ['investor'] }); var store = new Ext.data.Store({ model: 'Card', proxy: { type: 'ajax', url: 'xmlformat.xml', reader: { type: 'xml', record: 'investors' } }, listeners: { single: true, datachanged: function(){ Ext.getBody().unmask(); var items = []; store.each(function(rec){ alert(rec.get('investor')); }); and my xml file is: <?xml version="1.0" encoding="UTF-8"?> <root> <investors> <investor>Active</investor> <investor>Aggressive</investor> <investor>Conservative</investor> <investor>Day Trader</investor> <investor>Very Active</investor> </investors> <events> <event>3 Month Expiry</event> <event>LEAPS</event> <event>Monthlies</event> <event>Monthly Expiries</event> <event>Weeklies</event> </events> <prices> <price>$0.5</price> <price>$0.05</price> <price>$1</price> <price>$22</price> <price>$100.34</price> </prices> </root> wen i run the code only "Active" comes out. . . . i know that i'm doing something wrong but i'm not sure what.... please help . . . . .

    Read the article

  • nsdata to nsstring to nsdata

    - by Jayshree
    Hello everybody. I am calling the webservices. The web service returns data in xml format. Now the problem is the xml data is not being received in proper format. In place of "<", "" it returns in html format like-(<) and (>) . So i assigned the xmldata to a NsMutableString and replaced the escape characters so that the format of xml data is proper. Then i reassigned the NSMutableString to NSData so that i can parse the tags. but the problem is the xmlparser stops right where the xml data is. Where i replaced the tags. it doesnt go further. can anybody make me understand what is going on???? This is the xml response from webservice that i called. <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:GetCustomerInfoResponse xmlns:ns1="http://aa.somewebservice.com/phpwebservice"> <return xsi:type="xsd:string"> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;customer&gt;&lt;id&gt;1&lt;/id&gt;&lt;customername&gt;Hitesh&lt;/customername&gt;&lt;phonenumber&gt;98989898&lt;/phonenumber&gt;&lt;/customer&gt; </return> </ns1:GetCustomerInfoResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> And this is after i replaced the tags. <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:GetCustomerInfoResponse xmlns:ns1="http://a.somewebservice.com/phpwebservice"> <return xsi:type="xsd:string"> <?xml version="1.0" encoding="utf-8"?> <customer><id>1</id><customername>Hitesh</customername><phonenumber>98989898</phonenumber></customer> </return> </ns1:GetCustomerInfoResponse> </SOAP-ENV:Body></SOAP-ENV:Envelope> Now the problem is while parsing the parser only goes upto return tag. And then it is stuck there. It doesnt go any further. So wat do i do? anybody care to help me?

    Read the article

  • parse XML file that contains uniocode characters in iphone

    - by Jim
    Hi, I am trying to parse one XML file that contains some unicode characters.I tried to parse the file using NSXMLParser but i am unable to parse XML.Parser stops when it encounters any unicode characters. Is there any other good solution to parse XML file with unicode letters? Please suggest. Thanks, Jim.

    Read the article

  • kXML (XmlPullParser) not hitting END_TAG

    - by Tejaswi Yerukalapudi
    Hello all, I'm trying to figure out a way to rewrite some of my XML parsing code. I'm currently working with kXML2 and here's my code - byte[] xmlByteArray; try { xmlByteArray = inputByteArray; ByteArrayInputStream xmlStream = new ByteArrayInputStream(xmlByteArray); InputStreamReader xmlReader = new InputStreamReader(xmlStream); KXmlParser parser = new KXmlParser(); parser.setInput(xmlReader); parser.nextTag(); while(true) { int eventType = parser.next(); String tag = parser.getName(); if(eventType == XmlPullParser.START_TAG) { System.out.println("****************** STARTING TAG "+tag+"******************"); if(tag == null || tag.equalsIgnoreCase("")) { continue; } else if(tag.equalsIgnoreCase("Category")) { // Gets the name of the category. String attribValue = parser.getAttributeValue(0); } } if(eventType == XmlPullParser.END_TAG) { System.out.println("****************** ENDING TAG "+tag+"******************"); } else if(eventType == XmlPullParser.END_DOCUMENT) { break; } } catch(Exception ex) { } My input XML is as follows - <root xmlns:sql="urn:schemas-microsoft-com:xml-sql" xmlns=""> <Category name="xyz"> <elmt1>value1</elmt1> <elmt2>value2</elmt2> </Category> <Category name="abc"> <elmt1>value1</elmt1> <elmt2>value2</elmt2> </Category> <Category name="def"> <elmt1>value1</elmt1> <elmt2>value2</elmt2> </Category> My problem briefly is, I'm expecting it to hit XmlPullParser.END_TAG when it encounters a closing xml tag. It does hit the XmlPullParser.START_TAG but it just seems to skip / ignore all the END_TAGs. Is this how is it's supposed to work? Or am I missing something? Any help is much appreciated, Teja.

    Read the article

  • parse XML file that contains unicode characters in iphone

    - by Jim
    Hi, I am trying to parse one XML file that contains some unicode characters.I tried to parse the file using NSXMLParser but i am unable to parse XML.Parser stops when it encounters any unicode characters. Is there any other good solution to parse XML file with unicode letters? Please suggest. Thanks, Jim.

    Read the article

  • android : customer List Adatper + ArrayList

    - by Ram
    Team, Could you please help me debug the issue? ActivityAdapter activityAdapter = new ActivityAdapter(this,activityList); Log.d("list", "List Display - 1"); setListAdapter( activityAdapter ); Log.d("List", "list done"); It's throwing exception at the time of setListAdapter, 05-01 16:59:15.996: WARN/dalvikvm(251): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 05-01 16:59:15.996: ERROR/AndroidRuntime(251): Uncaught handler: thread main exiting due to uncaught exception 05-01 16:59:16.204: ERROR/AndroidRuntime(251): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.antennasoftware.xml/com.antennasoftware.xml.XMLParsing}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2454) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.os.Handler.dispatchMessage(Handler.java:99) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.os.Looper.loop(Looper.java:123) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.ActivityThread.main(ActivityThread.java:4310) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at java.lang.reflect.Method.invokeNative(Native Method) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at java.lang.reflect.Method.invoke(Method.java:521) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at dalvik.system.NativeStart.main(Native Method) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.ListActivity.onContentChanged(ListActivity.java:236) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.Activity.setContentView(Activity.java:1622) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at com.antennasoftware.xml.XMLParsing.onCreate(XMLParsing.java:36) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 05-01 16:59:16.204: ERROR/AndroidRuntime(251): ... 11 more Thanks in advance

    Read the article

  • iphone: caching and updating xml fields

    - by pJosh
    Thanks for your help. Here I have another question. I get the data through XMLParsing, now I want to store it in iphone's cache, and the XML Fields are updates every 12 hours.how can i check that XML Fields are change or not? and how can I store the data in iphone's cache memory so that evry it does not has to interact with web. Can anybody please help me???

    Read the article

  • Parsing xml files locally from assets folder using XmlPullParser

    - by Randolphg
    Im trying to parse a local xml file that I place in my assets folder. I've been trying to do this for almost a week now. Here is my test xml file Test1 Test2 Test3 Test4 Test5 I keep getting the same error: W/System.err(22458): org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT Code: public void xmlParser() throws XmlPullParserException, IOException, ParserConfigurationException, SAXException { Log.d("tag", "xmlParsing...."); Arithmetic arthm = new Arithmetic(); XmlPullParserFactory xmlPF = XmlPullParserFactory.newInstance(); xmlPF.setValidating(false); XmlPullParser xml = xmlPF.newPullParser(); InputStream raw = getApplication().getAssets().open("menu.xml"); xml.setInput(raw, null); xml.nextTag(); Log.d("tag", "start parsing...."); String elementText = null; String elemName = null; int nofTags = 0; while (xml.getEventType() != XmlPullParser.END_DOCUMENT) { Log.d("tag", "while(xml.next)..."); switch (xml.getEventType()) { case XmlPullParser.START_DOCUMENT: Log.d("tag", "while (xml.getEventType() != XmlPullParser.END_DOCUMENT)"); break; case XmlPullParser.START_TAG: Log.d("tag", " case XmlPullParser.START_TAG"); elementText = xml.getName(); Log.d("tag", "elementText = " + elementText); if (xml.getEventType() != XmlPullParser.END_TAG) { xml.nextTag(); } break; case XmlPullParser.TEXT: Log.d("tag", "case TEXT"); if (elementText.equals("menu") && xml.isWhitespace()) { Log.d("tag", "<" + elementText + ">"); arthm.menu_name = xml.getText(); Log.d("tag", "value " + xml.getText() + " added"); } else if (elementText.equals("item")) { arthm.description = xml.getText(); Log.d("tag", "value " + xml.getText() + " added"); } else if (elementText.equals("SUBCATEGORY NAME")) { arthm.subcategoryDesc.add(xml.getText()); Log.d("tag", "value " + xml.getText() + " added"); } else if (elementText.equals("SUBCATEGORY DESC")) { arthm.subcategoryName.add(xml.getText()); Log.d("tag", "value " + xml.getText() + " added"); } break; case XmlPullParser.END_TAG: Log.d("tag", "case END_TAG"); nofTags += 1; String tags = Integer.toString(nofTags); Log.d("tags", elementText + " number of tags" + tags); if (xml.nextTag() != XmlPullParser.START_TAG) { xml.next(); } break; case XmlPullParser.END_DOCUMENT: Log.d("tag", "case END_DOCUMENT"); break; default: break; } } Log.d("tag", "Success!"); } Thanks in advance.

    Read the article

1