Posts

Showing posts with the label xml

jaxb unmarshal xml element to object with some fields

Image
Clash Royale CLAN TAG #URR8PPP jaxb unmarshal xml element to object with some fields I have some classes: class Location { private Long id; private String roomTitle; protected Specialization specialization; } public class Specialization { private Long id; private boolean archived; private String title; } and xml: <location id="10"> <roomTitle>string</roomTitle> <specializationId>10</specializationId> </location> Can I unmarshal specializationId to Location.specialization.id ? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Android Spinner to determine Marker Colour

Image
Clash Royale CLAN TAG #URR8PPP Android Spinner to determine Marker Colour I have a spinner which I have created for a project in Android studio. The spinner takes the following values from an array in my strings.xml file. <string-array name="activity_types"> <item>Games</item> <item>Learn</item> <item>Fitness</item> <item>Make</item> <item>Explore</item> <item>Find</item> </string-array> I would like to create a function which places a marker of a particular colour onto my map in MainActivity i.e. selecting Games, will place an orange marker on the map, when 'Games' is selected and the 'Place' button (below) is pressed. However, I am not sure how to go about this? place_btn = (Button) findViewById(R.id.place_btn); place_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //what would handle the...

XSLT How to access attribute from different tag level?

Image
Clash Royale CLAN TAG #URR8PPP XSLT How to access attribute from different tag level? I am new to xsl & xslt. I am using xslt for xml to xml conversion. I have below xml file. I am iterating through REQ-IF/record using for-each loop and inside the loop I want to iterate REQ-IF/Attributes/Attribute to access @Name value. I tried using ../ but it only gives one level up values and do not allow me to iterate. Could you please help me with this? Thanks. <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <REQ-IF> <record> <Name>ABC</Name> <Presentationname>Task Record</Presentationname> <GUID>123</GUID> </record> <record> <Name>DEF</Name> <Presentationname>Role Record</Presentationname> <GUID>456</GUID> </record> <record> <Name>GHI</Name> ...

Handling Empty Tags in XML using Sax Parser, Java

Image
Clash Royale CLAN TAG #URR8PPP Handling Empty Tags in XML using Sax Parser, Java I'm Using Sax parser to handle a pre written xml file....i have no way of changing the xml as it is held by another application but need to parse data from it. The Xml file contains a Tag < ERROR_TEXT/> which is empty when no error is occurred. as a result the parser takes the next character after the tag close which is "n". i have tried result.replaceAll("n", ""); and result.replaceAll("n", ""); how to i get sax to recognise this is an empty tag and return the value as "" ? 4 Answers 4 You don't. It is SAXs job parse the data, not to make decisions on what the content of that data is supposed to be. In your parseHandler, store the string of the data in all your element, and when you go to process that element, do a string.trim() on ...

XML illegal characters (XMLTYPE parsing)

Image
Clash Royale CLAN TAG #URR8PPP XML illegal characters (XMLTYPE parsing) The following are usually mentioned as illegal XML characters: < > & ' " In PLSQL, when I convert an element having a VARCHAR2 value with the above characters to XMLTYPE, only < and & are reported as causes for XML non-well-formedness. 5 XML documents below, only the first (containing the less than mark) and the last one (containing the ampersand) are being flagged down as not-well formed. Is this as expected? --------------------------------- <?xml version="1.0" encoding="utf-8"?> <Request> <param1>test<message<param1> </Request> --------------------------------- <?xml version="1.0" encoding="utf-8"?> <Request> <param1>test>message<param1> </Request> --------------------------------- <?xml version="1.0" encoding="utf-8"?> <Request> <param...

MediaPlayer is not playing audio each button click same time

Image
Clash Royale CLAN TAG #URR8PPP MediaPlayer is not playing audio each button click same time I'm using MediaPlayer for alphabet. while clicking a single button audio is playing. each button click is not responsible. while audio end then working another button. but i want to set each button click play audio same time. how to do this? please inform me that how to solve this problem. sor_borno.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" an...

Referencing an XML doctype entity from XSLT

Image
Clash Royale CLAN TAG #URR8PPP Referencing an XML doctype entity from XSLT I'm trying to access the !ENTITY elements in an XML file's !DOCTYPE declaration when using an XSL file to transform the XML to HTML. In the XML, I have a widget element that has an attribute that corresponds to the !ENTITY name, and I want the XSLT to transform that into the !ENTITY 's value. !ENTITY !DOCTYPE widget !ENTITY !ENTITY XML File <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE root[ <!ENTITY Widget_Manual "Widget_Manual_File_Name.pdf" > ]> <root> <!-- I want to convert this to "Widget_Manual_File_Name.pdf" in the transform --> <widget entityIdent="Widget_Manual" /> </root> XSLT File <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"...

How to I break an XML node into 2 using XSLT 1.0

Image
Clash Royale CLAN TAG #URR8PPP How to I break an XML node into 2 using XSLT 1.0 I have an XML node with a child element that I need to break up into two Something like this <node margin="5pt" color="red">with some text and <seperator/> where the element continues</node> The result should be <node margin="5pt" color="red">with some text and </node> <node margin="5pt" color="red">where the element continues</node> By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Get a node's inner XML as String in Java DOM

Image
Clash Royale CLAN TAG #URR8PPP Get a node's inner XML as String in Java DOM I have an XML org.w3c.dom.Node that looks like this: <variable name="variableName"> <br /><strong>foo</strong> bar </variable> How do I get the <br /><strong>foo</strong> bar part as a String? <br /><strong>foo</strong> bar 8 Answers 8 There is no simple method on org.w3c.dom.Node for this. getTextContent() gives the text of each child node concatenated together. getNodeValue() will give you the text of the current node if it is an Attribute , CDATA or Text node. So you would need to serialize the node using a combination of getChildNodes() , getNodeName() and getNodeValue() to build the string. org.w3c.dom.Node getTextContent() getNodeValue() Attribute CDATA Text getChildNodes() getNodeName() getNodeValue() You can also do it with on...

Need help parsing XML Files

Image
Clash Royale CLAN TAG #URR8PPP Need help parsing XML Files Okay So I have 3 problems with my application atm: Directory.GetFiles So here is my code for problem #1 & #2: public void patchxml() { string xmldir = AppDomain.CurrentDomain.BaseDirectory + @"\tmp"; string xmlfile = Directory.GetFiles(xmldir, "*.xml"); XDocument xdoc = XDocument.Load(xmlfile[0]); //var element = xdoc.Elements("RequiredSystemVersion").Single(); not working //element.Value = "0"; not working //xdoc.Save(); not working } Here Is a sample of the xml file: <?xml version="1.0" encoding="utf-8"?> <ContentMeta> <RequiredSystemVersion>335675392</RequiredSystemVersion> <PatchId>0x01009bf0072d4800</PatchId> </ContentMeta> What I need to do is, that I need to change the required system version to...

A c# program that searches through multiple XML files and text to certain elements inside

Image
Clash Royale CLAN TAG #URR8PPP A c# program that searches through multiple XML files and text to certain elements inside I need to create a c# program that searches through multiple XML files and adds a post fix entered by the user to certain elements inside those XML files, those elements all have the string "_name" inside them, which is a blessing considering now I know what extra condition I can use to make sure I'm altering the correct elements, My basic understanding of how the process is gonna go is like this: 1- I let user browse through his computer and open the folder in which the XML files exist. 2- I let the program add "main" to the chosen path and so open the main.xml file which contains all the files I'll be needing to alter. (done) 3- create a loop that will open each file inside the main.xml file and store all its' contents inside a list of strings. 4- now compare each element inside the list with the content of each folder, and if a matc...

ImageView in circular through xml

Image
Clash Royale CLAN TAG #URR8PPP ImageView in circular through xml I'd Like to make any image from my ImageView to be circular with a border. ImageView I searched but couldn't find any useful information (anything that I tried didn't work). How can I achieve this through xml: Create an ImageView with certain src and make it circular with a border? ImageView How to change the src of ImageView in java code? – chenzhongpu Oct 22 '14 at 14:12 Good simple solution here stackoverflow.com/a/28096369/2162226 - all in Java, so you can apply this formatting dynamically to images at runtime – gnB Dec 22 '16 at 0:40 15 Answers ...