Invalid Expanded Name In LINQ to XML
Assuming I am reading this xml file using XLINQ. I encountered an error that says invalid expanded name. As i go through this xml file, i found a node images that contains element tags. The parent node is also an element tag. Since i don't use the images tag, I simply remove it using string manipulations. Below is the xml file and the solution:
C# Code:
<element> <id>2768687195</id> <title>Customer Service Representative</title> <body>Do you dream of being your own boss and choosing the work you do, when you work and who you work for? </body> <url>http://jobs.myjob.careercenter-servicecrew.html</url> <category> <id>job/customer_service</id> <name>Customer Service & Call Center Jobs</name> </category> <source> <id>www</id> <name>Oodle</name> </source> <location> <citycode>can:on:ajax</citycode> <name>Ajax</name> <state>ON</state> <country>CAN</country> <latitude>43.8610</latitude> <longitude>-79.0292</longitude> </location> <images> <element> <src>http://i.oodleimg.com/item/2768687195u_0s?1318626136</src> <width>100</width> <height>75</height> <alt>Customer Service Representativ</alt> <num>0</num> <size>s</size> </element> <element> <src>http://i.oodleimg.com/item/2768687195u_0m?1318626136</src> <width>144</width> <height>108</height> <alt>Customer Service Representativ</alt> <num>0</num> <size>m</size> </element> <element> <src>http://i.oodleimg.com/item/2768687195u_0l?1318626136</src> <width>208</width> <height>156</height> <alt>Customer Service Representativ</alt> <num>0</num> <size>l</size> </element> <element> <src>http://i.oodleimg.com/item/2768687195u_0x?1318626136</src> <width>100</width> <height>100</height> <alt>Customer Service Representativ</alt> <num>0</num> <size>x</size> </element> <element> <src>http://i.oodleimg.com/item/2768687195u_0j?1318626136</src> <width>100</width> <height>100</height> <alt>Customer Service Representativ</alt> <num>0</num> <size>j</size> </element> </images> <ctime>1318626135</ctime> <paid>Yes</paid> <revenue_score>6</revenue_score> <user> <id>51527855</id> <url>http://www.oodle.com/seller/arise-virtual-solutions/51527855/</url> <name>Arise Virtual Solutions</name> <photo>http://i.oodleimg.com/a/img_profilephoto.gif</photo> </user> <attributes> <company>Arise Virtual Solutions</company> <fee>No</fee> <full_time>Full Time</full_time> <has_photo>Thumbnail</has_photo> <job_title>Customer Service Representative</job_title> <user_id>51527855</user_id> </attributes> </element>
for (int ctr = 0; ctr < ListingSource.Length; ctr++) { if (ListingSource.Contains("<images>")) { int length = (ListingSource.IndexOf(" </images>") + 9) - ListingSource.IndexOf(" <images>"); ListingSource = ListingSourceRemove ListingSource.IndexOf("<images>"), length); } }
Comments
Post a Comment