In my app I am parsing 1 main and number of supporting xml files. The tags of my main xml files are as below:
<subject>
<chapter>
<chaptername>A</chaptername>
<pack>
<packname>A1</packname>
<packname>A2</packname>
</pack>
</chapter>
<chapter>
<chaptername>C</chaptername>
<pack>
<packname>C1</packname>
<packname>C1</packname>
</pack>
</chapter>
</subject>
When the first xml file is parsed, it lists the chapter names, and if I click any of the chapter names, it lists the pack names.
Now when I click on the pack name, I want the corresponding supporting xml file, which I have stored in the raw folder, to be parsed. How do I do this?
Look at QueryPath for parsing XML in PHP. After you parse the information you can either pull in other XML files or XML strings from a database based on what the clicked tag is. Use jQuery for the AJAX part of it.
Sources:
querypath.org
jquery.org
Related
I have a requirement where I should be able to take any XML document, parse it dynamically and store into a stack/deque for further processing.
Can someone recommend what is a good way to parse XMLs dynamically in JAVA.
Consider this XML
<Response>
<Stock>
<RecordID>130</RecordID>
<SegmentLength>0023</SegmentLength>
<Account>
<Number>233342</Number>
<Type>P</Type>
</Account>
</Stock>
<Stock>
<RecordID>030</RecordID>
<SegmentLength>1023</SegmentLength>
<Account>
<Number>255673</Number>
<Type>P</Type>
</Account>
</Stock>
</Response>
How can I write a method that parsers this XML dynamically and pushes elements into a stack/deque.
I cannot use DOM as DOM requires me to provide the element tag while parsing. The program should be able to accept any XML and parse it dynamically
I have a requirement to publish a HTML file from an XML file where the HTML file will show hard-coded values for the specific point in time they were present on the XML file (i.e. independent of XML changes after the HTML doc is created).
Example: XML File
<dvd>
<name>Titanic</name>
<price>10</price>
</dvd>
<dvd>
<name>Avatar</name>
<price>12</price>
</dvd>
Now I need to convert these into a HTML document whereby the values are hardcoded into the HTML
Example HTML File
<html>
<body>
<h1>DVD List</h1>
<table>
<tr ...>
<th>Name</th><th>Price</th>
<td>Titanic</td><td>10</td>
<td>Avatar</td><td>12</td>
I have tried using XSLT however this only provides a render of the XML document that is updated according to XML changes. I would require a point-in-time HTML document referring to the values as they were on the XML.
Perhaps there is an easy way to do this with existing technologies, or some simple custom Java code?
I am using below format to response for the webservices.
<Name>abc</Name>
<Detail>
<RESPONSE>
<Age>20</Age>
<Address>blahblah</Address>
<Mobile>12345</Mobile>
</RESPONSE>
</Detail>
Due to the requirements, I need to return xml format data insides the <Detail></Detail> tag.
In my java class, I parse using Xstream and format into xml and put insides the Detail tag.
But when I test using SOAPUI , I am getting extra <![CDATA[<RESPONSE>.. <</RESPONSE>]]> insdies Detail tag.
How can I avoid having those CDATA tag for the xml response?
<![CDATAP[......]]> is used to tell that the XML meaning of it should not be taken and to treat it as normal text that is called character data. so Parser won't seek for any XML meaning in it.
As Dave Newton and kshitij told it will automatically removed while converting it into object.
If you are not supposed to parse it as it is no issue to bother about it.
Dot in XML tag
I have problem with tags in xml file.
I have a lot of tags with dots for example <tag.state> example text </tag.state>
JavaScript (extJS), does not parse successfully tags with dots :\
XML file were generated automaticly, and I cannot influance in generated tags.. so is It possible to avoid this issue?
in cannot read tags in extJS
try with ' and dobule quatas " but also it fails...
fields: [ 'tag.state']
or
fields: [ "tag.state"]
I had a similar problem in java where my xml file could only have <string-array> and <item> and <name> etc. I just made a java file that ran through my xml (copied into a .txt) and rewrote everything with correct tags. I can share it with you if you would like.
I am developing xml editor using jsp and servlet. In this case i am using DOM parser.
I have one problem in XML editor ,
How to edit the following xml file without losing elements.
eg:
<book id="b1">
<bookbegin id="bb1">
<para id="p1">This is<b>first</b>line</para>
<para id="p2">This is<b>second</b>line</para>
<para id="p3">This is<b>third</b>line</para>
</bookbegin>
</book>
I try to edit the above xml file using dtd using jsp,servlet. but while i read the textvalue from xml, it return only first,second,third.How to read the 'This is' and 'line '. Then how to store back to the xml file using xpath.
thank in advance.
The <b> tag inside the <para> tag is another element, not a formatting tag (in XML). Therefore, you need to traverse down to it.
Like #JRL says, the <b> tags are cosnidered as well-formed XML and, as a consequence, splitted by your DOM processor.
I think youf ail to read other text elements because you only read text when an XML node has no more XML node, which is not your case here.