xml-parsing

How to modify a huge XML file by StAX?

浪子不回头ぞ 提交于 2019-12-18 11:34:48
问题 I have a huge XML (~2GB) and I need to add new Elements and modify the old ones. For example, I have: <books> <book>....</book> ... <book>....</book> </books> And want to get: <books> <book> <index></index> .... </book> ... <book> <index></index> .... </book> </books> I used the following code: XMLInputFactory inFactory = XMLInputFactory.newInstance(); XMLEventReader eventReader = inFactory.createXMLEventReader(new FileInputStream(file)); XMLOutputFactory factory = XMLOutputFactory

How to modify a huge XML file by StAX?

落花浮王杯 提交于 2019-12-18 11:33:59
问题 I have a huge XML (~2GB) and I need to add new Elements and modify the old ones. For example, I have: <books> <book>....</book> ... <book>....</book> </books> And want to get: <books> <book> <index></index> .... </book> ... <book> <index></index> .... </book> </books> I used the following code: XMLInputFactory inFactory = XMLInputFactory.newInstance(); XMLEventReader eventReader = inFactory.createXMLEventReader(new FileInputStream(file)); XMLOutputFactory factory = XMLOutputFactory

How to pass parameter to XSLT from Javascript function

拟墨画扇 提交于 2019-12-18 09:38:15
问题 I have scoured through numerous posts that try and explain how to achieve this, however none have helped me solve the problem. I have a HTML file which contains an XML parsing JavaScript function which in turn renders the XSLT file. The issue is, I have multiple 'records' in my XML file and I only want a single XSLT to render each of records (instead of a separate XSLT file per record). Based on the code below, please could someone advise on how I can pass a parameter from JavaScript

xml empty tags with PHP DOMDocument

偶尔善良 提交于 2019-12-18 09:16:32
问题 $xmlFile="<test>WPUBON</test> <test1>SAPRTA</test1> <test2></test2> <test3></test3> "; I have a String as above and i'm parsing this using PHP DOMDocuments $xml = new DOMDocument("1.0", "UTF-8"); $xml->loadXML($xmlFile); $xml->save("out/".$xmlFileName.".xml"); The output of empty tags comes as </test2> which i need to be <test2></test2> due to the application which process this xml needed as that. Please let me know a way to do this ! 回答1: Check the manual page of DOMDocument::save(). It

Finding a nonrecursive DOM subnode in Python using BeautifulSoup

亡梦爱人 提交于 2019-12-18 08:55:13
问题 Is there any way to find a nonrecursive DOM subnode in Python using BeautifulSoup? E.g. consider parsing a pom.xml file: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <groupId>com.parent</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <modelVersion>2.0.0<

How can I use PHP's various XML libraries to get DOM-like functionality and avoid DoS vulnerabilities, like Billion Laughs or Quadratic Blowup?

萝らか妹 提交于 2019-12-17 22:42:56
问题 I'm writing a web application that has an XML API in PHP, and I'm worried about three specific vulnerabilities, all related to inline DOCTYPE definitions: local file inclusion, quadratic entity blowup, and exponential entity blowup. I'd love to use PHP's (5.3) built in libraries, but I want to make sure I'm not susceptible to these. I found I can eliminate LFI with libxml_disable_entity_loader, but this doesn't help with inline ENTITY declarations, including entities that refer to other

Parsing XML into JSON

ぐ巨炮叔叔 提交于 2019-12-17 22:25:47
问题 I have an XML file, like <stock><name>AXL</name><time>19-07</time><price>11.34</price></stock> <stock><name>AIK</name><time>19-07</time><price>13.54</price></stock> <stock><name>ALO</name><time>19-07</time><price>16.32</price></stock> <stock><name>APO</name><time>19-07</time><price>13.56</price></stock> ...............more How can I parse this into JSON structure file? 回答1: For a simple solution, I recommend Jackson, a Java library for generating and reading JSON with an extension for XML, as

How to modify XML data in Dom parser

丶灬走出姿态 提交于 2019-12-17 21:14:57
问题 I am new working in Java and XML DOM parser. I had a requirement like read the xml data and store it inform of column and rows type. Example:sample.xml file <staff> <firstname>Swetha</firstname> <lastname>EUnis</lastname> <nickname>Swetha</nickname> <salary>10000</salary> </staff> <staff> <firstname>John</firstname> <lastname>MAdiv</lastname> <nickname>Jo</nickname> <salary>200000</salary> </staff> i need to read this XML file and store it in the above format: firstName,lastName,nickName

Need some help in parsing this XML in J2ME platform

☆樱花仙子☆ 提交于 2019-12-17 20:50:05
问题 Below mentioned is my XML, <?xml version="1.0" encoding="utf-8"?> <soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Response xmlns="http://tempuri.org/"> <Result> <mp_response> <data signature="something"> <outcome errorcode="0" errordescription="" errorsolution=""/> something </data> </mp_response> </Result> </Response> </soap:Body> </soap:Envelope> I wish to

XML Parsing and deserialization

╄→гoц情女王★ 提交于 2019-12-17 20:27:23
问题 I have a xml file which Im reading it from my class <Testclasses> <Class>new SomeClass1()</class> <class>new SomeClass2()</class> </Testclasses> so i have a method in the class which takes an argument as an object as below public List<Object> retriveValuesFromXml(){ .... This method parses the values from xml and reads the different object and returns a list of objects. } @Test public void someMethod1(){ ArrayList<Object> list_of_objects= retriveValuesFromXml(); for(Object x :list_of_objects)