Hi All,
I am working on xml parsing.
Here i am able to parse the xml page which is on server when i have given
the url directly.
but i need for dynamically created url
following is my code.
String tod = "IPH";
final Random myRandom = new Random();
String procod = String.valueOf(myRandom
.nextInt(9999 - 0000 + 1));

shopapi = "
http://api.shopvisible.com/ProductService.asmx/CreateBasicProduct?ClientName=IncipioBespoke&guid=fa63b21c-115a-e011-96ff-0026b95352bb&InboundProductXML=
";
shopapi = shopapi.concat("<Product>");
shopapi = shopapi.concat("<ProductPartNo>BCC-");
shopapi = shopapi.concat(tod);
shopapi = shopapi.concat("-");
shopapi = shopapi.concat(procod);
shopapi = shopapi.concat("</ProductPartNo>");
shopapi = shopapi.concat("<ProductUPC>bespoke</ProductUPC>");
shopapi = shopapi
.concat("<ProductCode>bespoke Custom Case</ProductCode>");
shopapi = shopapi
.concat("<Name>Customized
Case</Name><Brand>23</Brand><SubCategory>1</SubCategory>");
shopapi = shopapi.concat("<ImageName>");
shopapi = shopapi.concat(the_string_response1);
shopapi = shopapi.concat("</ImageName>");
shopapi = shopapi.concat("<Price>29.99</Price>");
shopapi = shopapi
.concat("<Orderable>true</Orderable><Quantity>50</Quantity><Weight>0.0</Weight><SubWeight>3</SubWeight>");

shopapi = shopapi.concat("<CustomText></CustomText>");
shopapi = shopapi.concat("<Xtra2></Xtra2>");
shopapi = shopapi.concat("</Product>");

SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();

/** Send URL to parse XML Tags */
// String a =
// "
http://api.shopvisible.com/ProductService.asmx/CreateBasicProduct?ClientName=IncipioBespoke&guid=fa63b21c-115a-e011-96ff-0026b95352bb&InboundProductXML=%3CProduct%3E%3CProductPartNo%3EBCC-IPH-9809%3C/ProductPartNo%3E%3CProductUPC%3Ebespoke%3C/ProductUPC%3E%3CProductCode%3Ebespoke%20Custom%20Case%3C/ProductCode%3E%3CName%3ECustomized%20Case%3C/Name%3E%3CBrand%3E23%3C/Brand%3E%3CSubCategory%3E1%3C/SubCategory%3E%3CImageName%3Ehttp://ncpo.cc/android/bespokecaseimages/553005.jpg%3C/ImageName%3E%3CPrice%3E29.99%3C/Price%3E%3COrderable%3Etrue%3C/Orderable%3E%3CQuantity%3E50%3C/Quantity%3E%3CWeight%3E0.0%3C/Weight%3E%3CSubWeight%3E3%3C/SubWeight%3E%3CCustomText%3E%3C/CustomText%3E%3CXtra2%3E%3C/Xtra2%3E%3C/Product%3E
";
// URL sourceUrl = new URL(a);
URL sourceUrl = new URL(shopapi);

/** Create handler to handle XML Tags ( extends DefaultHandler ) */
try {
XmlhandlerForShopapi myXMLHandler = new XmlhandlerForShopapi();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

please help me.

Thanks
Naveen.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to