xml-parsing

Parsing attribute in XML with DOM parser

删除回忆录丶 提交于 2019-12-17 19:55:42
问题 I am currently parsing XML, but im not quite sure how to parse the "status" attribute of "message": <message status="test"> <text>sometext</text> <msisdn>stuff</msisdn> </message> Here is the code, i have cut off everything unnecessary: NodeList nodeLst = doc.getElementsByTagName("message"); for (int s = 0; s < nodeLst.getLength(); s++) { Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element fstElmnt = (Element) fstNode; NodeList numberNmElmntLst = fstElmnt

How to prevent XXE attack

烈酒焚心 提交于 2019-12-17 18:38:18
问题 We had a security audit on our code, and it mentioned that our code is vulnerable to XML EXternal Entity (XXE) attacks. Explanation XML External Entities attacks benefit from an XML feature to build documents dynamically at the time of processing. An XML entity allows inclusion of data dynamically from a given resource. External entities allow an XML document to include data from an external URI. Unless configured to do otherwise, external entities force the XML parser to access the resource

How to parse an xml to java class with recycler view or in adapter of recyclerview

不问归期 提交于 2019-12-17 17:07:07
问题 I have an xml file which name it is Bookmark and it is into the xml folder. I want to parse xml to recycler view which I can show the list of the Bookmark in recycler view. The bookmark xml it is not in assets it is in res then xml folder. This is my code. Bookmark.xml in the xml folder <Bookmarks> <Bookmark id="1" icon="google.png" name="Google" searchUrl="https://www.google.com" hidden="true" /> <Bookmark id="2" icon="youtube_new.png" name="Youtube" searchUrl="http://m.youtube.com" />

How to get BeautifulSoup 4 to respect a self-closing tag?

眉间皱痕 提交于 2019-12-17 16:35:49
问题 This question is specific to BeautifulSoup4, which makes it different from the previous questions: Why is BeautifulSoup modifying my self-closing elements? selfClosingTags in BeautifulSoup Since BeautifulStoneSoup is gone (the previous xml parser), how can I get bs4 to respect a new self-closing tag? For example: import bs4 S = '''<foo> <bar a="3"/> </foo>''' soup = bs4.BeautifulSoup(S, selfClosingTags=['bar']) print soup.prettify() Does not self-close the bar tag, but gives a hint. What is

SAX parsing and special characters

风流意气都作罢 提交于 2019-12-17 14:55:13
问题 I want to parse some data from an xml file using SAX parser. My xml is as follows: <categories> <cat>Pies & past</cat> <cat>Fruits</cat> </categories> In order to parse this data I extend DefaultHandler. The output after parsing is: cat 1 = Pies cat 2 = & cat 3 = past cat 4 = Fruits Why is this happening instead of getting: cat 1 = Pies & past cat 2 = Fruits 回答1: My guess is that you are treating each call to characters as delivering the complete text for a cat element. You should code your

decode string encoded in utf-8 format in android

 ̄綄美尐妖づ 提交于 2019-12-17 10:59:30
问题 I have a string which comes via an xml , and it is text in German. The characters that are German specific are encoded via the UTF-8 format. Before display the string I need to decode it. I have tried the following: try { BufferedReader in = new BufferedReader( new InputStreamReader( new ByteArrayInputStream(nodevalue.getBytes()), "UTF8")); event.attributes.put("title", in.readLine()); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch

How to create a XML object from String in Java?

心不动则不痛 提交于 2019-12-17 10:35:25
问题 I am trying to write a code that helps me to create a XML object. For example, I will give a string as input to a function and it will return me a XMLObject. XMLObject convertToXML(String s) {} When I was searching on the net, generally I saw examples about creating XML documents. So all the things I saw about creating an XML and write on to a file and create the file. But I have done something like that: Document document = new Document(); Element child = new Element("snmp"); child

oracle plsql: how to parse XML and insert into table

[亡魂溺海] 提交于 2019-12-17 10:17:52
问题 How to load a nested xml file into database table ? <?xml version="1.0" ?> <person> <row> <name>Tom</name> <Address> <State>California</State> <City>Los angeles</City> </Address> </row> <row> <name>Jim</name> <Address> <State>California</State> <City>Los angeles</City> </Address> </row> </person> In this xml, person is the table name , name is the filed name, Tom is its filed value. Address is a subtable and state and city is two column inside Address. I want to insert the person row into

How to post string with special character and Thai Language using XML parsing in Objective C?

匆匆过客 提交于 2019-12-17 03:45:29
问题 I am new in iOS and I am facing problem regarding to post string containing special character. My code is like this in DidFinishLoading: NSXMLParser *myNSXMLParserPostObj=[[NSXMLParser alloc]initWithData:myNSMDataPostFromServer]; myNSXMLParserPostObj.delegate=self; [myNSXMLParserPostObj parse]; NSLog(@"%@",myNSXMLParserPostObj.parserError); NSString *responseStringWithEncoded = [[NSString alloc] initWithData: myNSMDataPostFromServer encoding:NSUTF8StringEncoding]; //NSLog(@"Response from

How to post string with special character and Thai Language using XML parsing in Objective C?

試著忘記壹切 提交于 2019-12-17 03:45:13
问题 I am new in iOS and I am facing problem regarding to post string containing special character. My code is like this in DidFinishLoading: NSXMLParser *myNSXMLParserPostObj=[[NSXMLParser alloc]initWithData:myNSMDataPostFromServer]; myNSXMLParserPostObj.delegate=self; [myNSXMLParserPostObj parse]; NSLog(@"%@",myNSXMLParserPostObj.parserError); NSString *responseStringWithEncoded = [[NSString alloc] initWithData: myNSMDataPostFromServer encoding:NSUTF8StringEncoding]; //NSLog(@"Response from