Menu
  • HOME
  • TAGS

Error during deserializing XML

c#,xml,serialization,deserialization

Use the [XmlElement] attribute: [XmlElement(ElementName = "StyleProperties", Namespace="http://schemas.datacontract.org/2004/07/PPT_Styles_Tool")] public class StyleProperties { //... Also, if you use the XmlSerializer to serialize, then you should use the XmlSerializer to deserialize. Not the DataContractSerializer....

Springboot REST application should accept and produce both XML and JSON

java,xml,rest,jackson,spring-boot

Try to add a @XmlRootElement(name="myRootTag") JAXB annotation with the tag you use as the root tag to the class MatchRequest. I have had similar issues when using both XML and JSON as transport format in a REST request, but using moxy instead of Jackson. In any case, proper JAXB annotations...

How to set up XPath query for HTML parsing?

python,xml,parsing,xpath,lxml

It is important to inspect the string returned by page.text and not just rely on the page source as returned by your Chrome browser. Web sites can return different content depending on the User-Agent, and moreover, GUI browsers such as your Chrome browser may change the content by executing JavaScript...

Create XSD based on root element

java,xml,parsing,xsd

Using XSL 2.0 you can have multiple output documents and can define every file name, file content, etc. Default java support for XSL 2.0 is far from perfect, so I use the incredible Saxon (you can download saxon-he here, unzip it and add saxon9he.jar to your project). This is the...

Adding custom style to button in styles.xml gives error

android,xml

You can switch rendering target version < 22. Try it once. You can install android versions from these steps as shown in screenshots. ...

Tagging values in HTML document for automated extraction

html,xml,html5

If you are using them as meta-documents and they are sent to the parser, then converted as HTML and as long as the converted HTMLs do not have any irrelevant tags, it is fine! So, if the following code: <requirement> THE REQUIREMENT HERE </requirement> Gets converted into something like: <!--...

Adding Post data to XML String

php,xml,post

You need to add " around the value not single '. $XPost = "<MinPrice>{$_POST['first_name']}</MinPrice>"; with dobule quote you can do this $XPost = "<MinPrice>".$_POST["first_name"]."</MinPrice>"; Change your code like that. $strXml = '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <SubmitLead...

get XML tags from URL using javascript

javascript,ajax,xml

Here is a basic example, it uses YQL to bypass CORS var pre = document.getElementById('out'), oReq = new XMLHttpRequest(), url = 'http://open.api.ebay.com/shopping?version=581&appid=EBAYU91VTR1SQ8H917BC11O3BW8U4J&action=getResults&callname=FindItemsAdvanced&QueryKeywords=Aston+Martin+V12+Vanquish&categoryId=220', yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + url + '"') + '&format=xml&callback'; function updateProgress(oEvent) { if...

Extracting XML data from CLOB

sql,xml,oracle

Use xmltable. Data setup: create table myt( col1 clob ); insert into myt values('<ServiceDetails> <FoodItemDetails> <FoodItem FoodItemID="6486" FoodItemName="CARROT" Quantity="2" Comments="" ServingQuantityID="142" ServingQuantityName="SMALL GLASS" FoodItemPrice="50" ItemDishPriceID="5336" CurrencyName="INR" CurrencyId="43"/> </FoodItemDetails> <BillOption> <BillDetails TotalPrice="22222" BillOption="cash"/> </BillOption> <Authoritativeness/> </ServiceDetails>' ); commit; Query:...

Selecting data in XSL from different sections of XML

xml,xslt

i haven't tried it .. but i think a leading '/' is missing here : <xsl:value-of select="root/generatorList/generator/E"/> try this please : <xsl:value-of select="/root/generatorList/generator/E"/> otherwise the xslt engine is trying to find a relative path "root/generatorList/generator/E" starting at the matched element (/root/fiberList/fiber) of the template but there is no /root/fiberList/fiber/root/generatorList/generator/E....

PowerShell XML formatting issue

xml,powershell

You're missing a set of parentheses (()) at the end of $XmlWriter.WriteEndElement: $xmlWriter.WriteStartElement("Disk$count") # Add tag for each drive $xmlWriter.WriteElementString("DriveLetter","$DriveLetter") # Write Drive Letter to XML $xmlWriter.WriteElementString("DriveSize","$DriveSize") # Write Drive Size to XML $xmlWriter.WriteElementString("DriveFreeSpace","$DriveFreeSpace") # Write Drive Free Space to XML $xmlWriter.WriteEndElement() # <-- Closing Drive Tag - don't forget...

Can I create a macro or shortuct for a step of XPath in XQuery?

xml,xpath,macros,xquery

XQuery does not know such macros, you could of course use any preprocessor to do such things. But I'd rather define a function for this: declare function local:outward($context as item()) { $context/ancestor-or-self::* }; Functions can also be applied in axis steps (remember to pass the current context .): let $xml...

Convert contents of an XmlNodeList to a new XmlDocument without looping

c#,xml,xpath,xmldocument,xmlnodelist

If you're happy to convert it into LINQ to XML, it's really simple: XDocument original = ...; // However you load the original document // Separated out for clarity - could be inlined, of course string xpath = "//Person[not(PersonID = following::Person/PersonID)]" XDocument people = new XDocument( new XElement("Persons", original.XPathSelectElements(xpath) )...

XML-XSLT-XPATH : How to convert multiple XML elements to a string, separated by semicolon

xml,xslt,xpath,xslt-2.0

you could use something like: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>UserNames: &quot;</xsl:text> <xsl:value-of select="/Users/user/username" separator=";"/> <xsl:text>&quot;&#xA;</xsl:text> <xsl:text>Names: &quot;</xsl:text> <xsl:value-of select="/Users/user/name" separator=";"/>...

how to make xml values comma seperated using XPath, XQuery in Sql Server

sql-server,xml,xpath,xquery

SQL Server does not implement the xPath function string-join, so you would need to adopt a two step process, the first would be to extract all the terms to rows using nodes(); SELECT n.value('.', 'VARCHAR(100)') AS parsedString FROM #temp AS t CROSS APPLY t.Response.nodes('/error/description2') r (n); Which gives you your...

How to get xml attribute and values using JAXB

xml,parsing,jaxb

I suppose you have your class MessageMapping.java which has in turn a list (or one? dunno) of message of type Message.java. Message.java in turn will be structured with a list of Field of type Field.java. The classes will be as follow: @XmlAccessorType(XmlAccessType.FIELD) public class Field { @XmlAttribute private String tag;...

How to calculate max string-length of a node-set?

xml,xslt,xslt-1.0,libxslt

<xsl:variable name="max_a_width"> <xsl:for-each select="data"> <xsl:sort select="string-length(@a)" data-type="number" /> <xsl:if test="position() = last()"> <xsl:value-of select="string-length(@a)" /> </xsl:if> </xsl:for-each> </xsl:variable> This is the general method of picking from an ordered list of derived values in XSLT 1.0. If you want to pick the minimum/maximum from actual (natively sortable) values, you can take...

Validation error in XML Schema for complexType

xml,xsd,xml-validation

XML tags are CaSe SenSitIve. complexType != complextype. You need to fix that throughout your schema - it's expecting to find <xs:complexType> but instead finding <xs:complextype>, which is not valid. It looks like you will have similar problems elsewhere - for example, simpleType, maxLength are other tags that have different...

odoo v8 - Field(s) `arch` failed against a constraint: Invalid view definition

python,xml,view,odoo,add-on

You have made silly mistake in defining _columns. _colums is not valid dictionary name for fields structure. Replace this by _columns and restart service and update module. ...

XML, XSL namespaces

xml,xslt,namespaces

To produce a valid output HTML document you just need to add exclude-result-prefixes="xsi xslFormatting" on the <ins:stylesheet> (root) element of your stylesheet. But indeed in your stylesheet you don't use the xsi and xslFormatting namespaces anywhere. Thus you could also modify your stylesheet by removing these namespaces declarations, leading you...

Xml schema regex to not allow white spaces alone

regex,xml,xsd

You're on the right track using <xs:whiteSpace> restriction, but the value should be preserve in order to not modify the original whitespace. You can use this pattern: [\w\d ]*[\w\d][\w\d ]* The central part ([\w\d]) says that a letter or a digit must appear. Before and after that compulsory alphanumeric character,...

R readHTMLTable failed to load external entity [duplicate]

xml,r,connection

In the link that I mentioned in the comment, you can find solutions using RCurl and httr package. Here, I provide the solution using rvest package. library(rvest) kk<-html("http://en.wikipedia.org/wiki/List_of_S%26P_500_companies")%>% html_table(fill=TRUE)%>% .[[1]] //table 1 only head(kk) Ticker symbol Security SEC filings GICS Sector GICS Sub Industry Address of Headquarters 1 MMM 3M...

Concatenate two XML templates in Python

python,xml,elementtree

One (unorthodox) way of doing it is like so: template1 = \ ''' <ParentTag> <orders orderid="%s"> <unitprice>%s</unitprice> <quantity>%s</quantity> </orders>%s </ParentTag> ''' template2 = \ ''' <details> <productid>%s</productid> <productname>%s</productname> </details> ''' Code: output = "" if (condition is met): output += output % template1(orderid, unitprice, quantity, "") else: output += template1...

Roku animation using animated sprites, how to create the tedious xml

xml,animation,sprite-sheet,roku,brightscript

Actually, you don't have to use XML files for sprite animations. Just be aware that frame's dimensions must be set. Follow the example bellow for a loading sprite with 128x128 dimensions and 12 frames: compositor = CreateObject("roCompositor") compositor.SetDrawTo(screen, &h80) compositor.NewAnimatedSprite(576, 296, GetLoadingSpriteRegions()) Function GetLoadingSpriteRegions() as Object arr = [] bitmap=createobject("robitmap","pkg:/images/loader_sprite.png")...

XSLT get all nodes with text

xml,xslt

It's unclear to me what location is, but this sample: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:template match="/"> <sample> <xsl:call-template name="interpret_text"> <xsl:with-param name="location" select="."/> </xsl:call-template> </sample> </xsl:template> <xsl:template name="interpret_text"> <xsl:param name="location"/> <xsl:for-each select="$location//text()"> <xsl:if...

Retrieving an XML node value with TSQL?

sql-server,xml,tsql,soap

Here is the solution: DECLARE @xml xml SELECT @xml = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <webregdataResponse> <result>0</result> <regData /> <errorFlag>99</errorFlag> <errorResult>Not Processed</errorResult> </webregdataResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>' declare @table table...

Ruby- get a xml node value

ruby,xml

Try to use css instead of xpath, this will work for you, doc = Nokogiri::XML(response.body) values = doc.css('Name').select{|name| name.text}.join',' puts values => Ram,Sam ...

Remove all nodes in a specified namespace from XML

c#,xml,linq-to-xml

Iterating through elements then through attributes seems not too hard to read : var xml = @"<?xml version='1.0' encoding='UTF-8'?> <root xmlns:test='urn:my-test-urn'> <Item name='Item one'> <test:AlternativeName>Another name</test:AlternativeName> <Price test:Currency='GBP'>124.00</Price> </Item> </root>"; var doc = XDocument.Parse(xml); XNamespace test = "urn:my-test-urn"; //get all elements in specific namespace and remove doc.Descendants() .Where(o => o.Name.Namespace...

How to convert XML into PDF/A using java api?

xml,pdfa

You can use Apache FOP API and you need to write XSLT style for your output PDF. This API will help to convert your XML and XSLT stylesheet into PDF/PDF-A.

How get value from property file to input in springConfig.xml

java,xml,spring-mvc

Look at this line of your stack trace: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailSender' defined in class path resource [springConfig.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'port'; nested exception is java.lang.NumberFormatException: For input...

How to parse comment from XML with XMLEventReader?

java,xml,xml-parsing

You can use javax.xml.stream.events.Comment.getText() to get the string data of a comment, or the empty string if it doesn't exist: ((javax.xml.stream.events.Comment) event).getText() ...

Giving a prepared SOAP response by Java

java,xml,web-services,soap

Sure you can. Even within the same Java program. Use Java HTTP Server. few lines of code and you have functional http server.

Java XPath returns single result instead of NodeSet

java,xml,dom,xpath

My guess is that you make a mistake while processing the result NodeList. Try the following approach: NodeList results = (NodeList) xpath.evaluate(..); for (int i = 0; i < nodelist.getLength(); i++) { Node node = (Node) nodelist.item(i); ... } ...

Convert meters to foot in xml data via xsl transformation

xml,xslt,openstreetmap

There are several issues with your approach. For example, instead of: <node><xsl:value-of select="node"/></node> which creates empty node elements (because your node elements are empty), you should be using something like: <node><xsl:copy-of select="@*"/></node> and instead of: <xsl:for-each select="/tag"> which selects nothing, because tag is not a child of the / root...

How to store a string in xml file and use it in _Layout in MVC

c#,xml,asp.net-mvc,asp.net-mvc-4

Sourced: from this link The web.config (or app.config) is a great place to store custom strings: in web.config: <appSettings> <add key="message" value="Hello, World!" /> </appSettings> in cs: string str = ConfigurationSettings.AppSettings["message"].toString(); ...

Parsing XML array using Jquery

javascript,jquery,xml,jquery-mobile

EMI and CustomerName are elements under json so you can use .find() to find those elements and then text() to get its value. $(data).find("json").each(function (i, item) { var heures = $(item).find("CustomerName").text(); var nbr = $(item).find("EMI").text(); console.log(heures); }); .attr() is used to get the attribute value of an element like in...

Using LINQ to reference XML local Xelements

c#,xml,linq

You always have the option to create extension methods to find elements by local name. Whether you like it or not, you have to "use an if within the foreach," that's an ovherhead you'll have to accept. This implementation is in terms of LINQ but you could always write it...

Remove XML Node text using XSLT

xml,xslt,xslt-2.0

Here's one way: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="c"> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet> Here's another:...

Altering XML file format in C#

c#,xml,formatting

It sounds like your XML is coming straight from your database, which means you need to transform it into something else based on the structure you have presently. While you could learn XSLT, you could also do this using LINQ to XML, querying the document you have parsed in order...

XElement.Value is stripping XML tags from content

c#,.net,xml,xml-parsing,xelement

As others have said, this format is truly horrible, and will break as soon as the XML embedded in the JSON will contain double quotes (because in the JSON they will be encoded as \", which will make the XML invalid). The JSON should really be embedded as CDATA. Now,...

simplexml_load_file to file creating an empty file

php,xml

simplexml_load_file() itself returns an object on success, not a string, while file_put_contents() as a second argument expects a string to be written. So you're trying to save an object instead of raw string. In this scenario you can simply do something like this: $xml = file_get_contents($signedUrl); $file = "c:/wamp/www/products.xml"; file_put_contents($file,...

C# XML: System.InvalidOperationException

c#,xml

Is "User Info" and "Course Data" is a different entity. If it is so, I think you may encapsulate them in one entity. XmlTextWriter writer = new XmlTextWriter(path, System.Text.Encoding.UTF8); writer.WriteStartDocument(true); writer.Formatting = Formatting.Indented; writer.Indentation = 4; writer.WriteStartElement("My Entity"); /* It is a biggest one*/ writer.WriteStartElement("User Info"); writer.WriteStartElement("Name"); writer.WriteString(userName); writer.WriteEndElement(); writer.WriteStartElement("Tutor...

Update SQL Server table using XML data

sql-server,xml

You have 2 errors in your xml: First is nonmatching root tags. Second, more important, you are quering nodes('/Aprroval/Aprrove'), but inner tag is Approve not Aprrove. Fiddle http://sqlfiddle.com/#!3/66b08/3...

C# Validate DataSet filled with DGV data as XML

c#,xml,validation,datagridview,xsd

If the question is why can't the file be deleted, it is because the XmlReader has the file open - call read.Close() before trying to delete the file.

How to get xml Nodes which are in lower case using XSLT 1.0

xml,xslt,xpath,xslt-1.0

All you need is the identity template to copy existing nodes... <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> Then another template to ignore nodes that aren't lower-case. In XSLT 1.0 this can be done by using the translate statement, to translate uppercase letters to lowercase, and checking if the result...

type conversion performance optimizable?

c#,xml,csv,optimization,type-conversion

IEnumerable<string> values = new List<string>(); values = … Probably not going to be a big deal, but why create a new List<string>() just to throw it away. Replace this with either: IEnumerable<string> values; values = … If you need values defined in a previous scope, or else just: Enumerable<string> values...

What is the xpath for retrieving all attribute nodes (whatever be the attributes name) with a specified value?

java,xml,xpath

Well //@* gives you all attribute nodes, add a predicate //@*[. = 'zzz'] and you have all attribute nodes with the value zzz.

Collect strings after a foreach loop

c#,xml,foreach

Yep, you need to do the adding within the loop. I'd use a List<string> as it supports LINQ: XmlNodeList skillNameNodeList=SkillXML.GetElementsByTagName("name"); List<string> skills = new List<string>(); foreach (XmlNode skillNameNode in skillNameNodeList) { skills.Add(skillNameNode.Attributes["value"].Value); } ...

XML values of the same attribute in different elements cannot repeat

xml,xsd

You can use xs:unique to constrain Reference_number to be unique: <?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Items"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="Item"> <xs:complexType> <xs:sequence> <xs:element name="Name" type="xs:string" /> <xs:element name="Reference_number" type="xs:string" />...

Sequence number for static and dynamic rows in XSLT 2.0

xml,xslt-2.0

Would this XSLT do: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" /> <xsl:strip-space elements="*"/> <xsl:template match="/*"> <xsl:apply-templates select=".//line"/> </xsl:template> <xsl:template match="line"> <xsl:variable name="pos" select="position() + (3 * count(preceding::data))"/> <xsl:value-of select="concat(format-number($pos, '00000 '), ., '&#xa;')"/> </xsl:template> <xsl:template...

Chunking XML with XMLStreamReader failing

java,xml,jaxb,stax

Here is the solution: ClassPathResource classPathResource = new ClassPathResource("samples/form2/data/test.xml"); XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, true); XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(classPathResource.getInputStream()); JAXBContext jaxbContext = JAXBContext.newInstance(EntityRecordData.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); int eventType = xmlStreamReader.next();...

Multiple results on a Xml stack with lml (Python)

python,xml

If it's the case that you want your script to build an XML packet as you've shown, there are a few issues. You're doing a lot of swapping of variables around, simply to convert them to strings - for the most part you can just use the Python string conversion...

Reading data from an XML File Using R

xml,r

If you're willing to give xml2 a go, you can get to begin in a few lines: library(xml2) library(magrittr) # get a vector doc <- read_xml("~/Dropbox/Data.xml") doc %>% xml_find_all("//d1:event/d1:begin", ns=xml_ns(doc)) %>% xml_text() %>% as.numeric() ## [1] 0.24 0.73 1.25 1.75 2.24 2.75 3.27 3.76 4.30 4.77 5.28 5.78 6.32 6.82...

group siblings by identifying the first node of a certain type in sequence

xml,xslt,xpath

Try it this way: <xsl:key name="kFirstText" match="*[not(self::type1[not(preceding-sibling::*[1][self::type1])])]" use="generate-id(preceding-sibling::type1[not(preceding-sibling::*[1][self::type1])][1])"/> This excludes the "leader" nodes from the group retrieved by the key....

Transform XML to another XML using XSL based on some condition

xml,xslt

Your xsl is not valid This one is correct and gives you the result expected <?xml version="1.0" ?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:element name="parent"> <xsl:apply-templates select="/root/gereratorList/generator"/> </xsl:element> </xsl:template> <xsl:template match="generator"> <xsl:if test="id='10'"> <xsl:element name="child"> <xsl:element name="test"> <xsl:value-of select="A"/>...

Adding a child attribute to the parent element in xslt 1.0

xml,xslt,xpath,xslt-1.0

It's difficult to provide an answer without seeing the input. I believe you need to do something like the following: XSLT 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="visualChildren"> <xsl:variable name="bundles"> <xsl:call-template name="create-bundles"> <xsl:with-param name="n" select="4" />...

XSL - iterate through elements and update based on the node index from another xml file

xml,xslt

An XSL transformation that meets your requirement may be like the following: <?xml version="1.0" encoding="utf-16" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <!-- the update source file: --> <xsl:param name="usource" select="'updatesource.xml'"/> <xsl:template match="Material"> <!-- Material's position: --> <xsl:variable name="pos"> <xsl:value-of select="count(preceding::Material)+1"/> </xsl:variable>...

XML Post from form using curl PHP

php,xml,curl

$data = array( "line1" => "sample data", "line2" => "sample data 2", ); $data_string = json_encode($data); $url = "http://test.com/webservicerequest.asmx"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); // set url to post to curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string))...

Serialize/Deserialize class containing byte array property into XML

c#,.net,xml,serialization,.net-4.0

As you've noticed, there are lots of characters that may not be present in an XML document. These can be included in your data, however, using the proper escape sequence. The default settings of the XmlTextReader cause it to mishandle this -- I think it interprets the escape sequences prematurely,...

removing a parent node dependig upon child node using xslt

xml,xslt

i want an xslt template which removes the other event node along with child nodes in which other event type value is OriginalCommitDateTime. The standard method to exclude specific nodes is to start with the identity transform template to copy all nodes as the rule, then add an empty...

Deserializing or parse XML response in Symfony2

php,xml,symfony2,deserialization,jmsserializerbundle

It depends on your intention. If you want to directly push part or all of the XML to an entity/document object for saving to a database then the JMSSerializerBundle can do this very smartly and is definitely the best way to do it. If however you just want to extract...

XMLPullParser black diamond question marks with certain characters

android,xml,character-encoding,xmlpullparser,questionmark

Content encoding and character encoding are not the same thing. Content encoding refers to compression such as gzip. Since getContentEncoding() is null, that tells you there's no compression. You should be looking at conn.getContentType(), because the character encoding can usually be found in the content-type response header. conn.getContentType() might return...

Add XElement dynamically using loop in MVC 4?

c#,xml,asp.net-mvc-4,for-loop

This is the complete code [HttpPost] public ActionResult SURV_Answer_Submit(List<AnswerQuestionViewModel> viewmodel, int Survey_ID, string Language) { if (ModelState.IsValid) { var query = from r in db.SURV_Question_Ext_Model.ToList() join s in db.SURV_Question_Model on r.Qext_Question_ID equals s.Question_ID where s.Question_Survey_ID == Survey_ID && r.Qext_Language == Language orderby s.Question_Position ascending select new { r, s };...

Magento simplexml_load_string() error location

php,xml,magento

It's something related with /var/www/html/app/code/core/Mage/Core/Model/Layout/Update.php so I would edit that file and I would go to the line 450. Just before that line write: Mage::log(print_r($filename, true)); Make sure that your logging is enabled and refresh the page. After that, take a look to var/log/system.log. The last xml is probably what...

how to insert the xml data to sql server using c#?

sql,xml,stored-procedures,sql-insert

You have a few options: You can read the XML nodes before inserting into the database, and insert normalized table column values. You can shred the XML in a stored procedure, by passing the XML string as an input parameter. You can read up on how to shred the XML...

HTMLPurifier without XML declaration

php,xml,htmlpurifier

you need cut result string $n = strlen('<?xml encoding="utf-8" ?>'); $content_text_fixHTML = substr($H->purify($content_text), $n); ...

Remove an XML node by its content

c#,xml

Actually the program as posted originally works fine, there is just one small error: "ParentNode.RemoveChild()" should be called on node instead of doc.

Javascript - accessing an object with duplicate names

javascript,arrays,xml,object

I actually looked around and figured out how to do this. I found it under a different topic but figured that I might help anyone else with this specific question. To get to these multiple array items, you have to put in the index like this: console.log(jsonXML.ProfileGroup.File["0"].Profile.WayPt["0"].distance); When iterating through...

Unable to construct Document object from xml string

java,xml,xpath,xml-parsing

As Arthur Elrich pointed out in the comments, you should make the factory namespace aware and provide a namespace context to the XPath instance. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse( new InputSource(new StringReader(...))); XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(new MyNamespaceContext()); String s = xpath.evaluate("//location:address/text()",...

Error when building an XDocument

c#,xml,linq,xpath,linq-to-xml

You can ignore pretty much all your code, the issue is just this: XDocument people = new XDocument("Persons"); You can't create an XDocument containing a string, you need to add an element: XDocument people = new XDocument( new XElement("Persons", original.XPathSelectElements(xpathFilterDups))); ...

Ninject generic type xml binding

c#,xml,generics,ninject

You want to bind open generic types, so this type definition should do the trick: <bind service="Base.IJsonProvider`1, Base" to="Base.JsonProvider`1, Base" name ="Config"/> ...

XSLT for-each statement not iterating proper amount of times

xml,xslt

Try it this way? <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/template/L"> <html> <body> <ul> <xsl:for-each select="Q"> <li> <xsl:value-of select="text()"/> <ul> <xsl:for-each select="R"> <li> <xsl:value-of select="."/> </li> </xsl:for-each> </ul> </li> </xsl:for-each> </ul> </body> </html> </xsl:template> </xsl:stylesheet> Explanation: When...

How to Get more than one Childnode innertext using C#?

c#,sql,xml,xmlnode

This should work : XmlNodeList xnList2 = xml.SelectNodes("/roor/body/queries"); foreach (XmlNode xn2 in xnList2) { foreach (XmlNode childNode in xn2.ChildNodes) { queries = childNode.InnerText; // text should return only first query text, but I need all the query text query_string = "INSERT INTO Customer_Queries values (@query)"; using(SqlConnection myConnection = new SqlConnection(constr))...

Python Resize Multiple images ask user to continue

python,xml,image,resize

Change your final loop to: for idx, image in enumerate(imgPath): #img resizing goes here count_remaining = len(imgPath) - (idx+1) if count_remaining > 0: print("There are {} images left to resize.".format(count_remaining)) response = input("Resize image #{}? (Y/N)".format(idx+2)) #use `raw_input` in place of `input` for Python 2.7 and below if response.lower() !=...

Ruby on Rails posting to an API using javascript via a proxy

javascript,ruby-on-rails,ruby,xml,api

Net::HTTP is Ruby's built in library for sending HTTP requests. Rails also has built in features for serializing models to XML. Lets say you bind your form to a User model: class User < ActiveModel::Base # attr_accessor is not needed if these are real DB columns. attr_accessor :firstname attr_accessor :surname...

Is complexity of scala.xml.RuleTransformer really exponential?

xml,scala,time-complexity

This will be not a very rigours analysis, but the problem seems to be with the BasicTransformer's transform(Seq[Node]) method[1]. The child transform method will be called twice for a node which is changed. Specifically in your example all the nodes will be called twice for this reason. And you are...

About sorting based on the counting of subelements

xml,xslt

You can use a key in order to count the properties in the sort instruction. A stylesheet containing the following: <xsl:key name="p" match="property" use="@agency"/> <xsl:template match="/immo"> <result> <xsl:for-each select="agency"> <xsl:sort select="count(key('p', @name))"/> <res id="{ @name }" count="{ count(key('p', @name)) }"/> </xsl:for-each> </result> </xsl:template> when applied to the following input: <immo>...

Converting XSD 1.1 to 1.0 - Validation Error

xml,xsd

You can't get this to work with XSD 1.0. An "all" is not allowed as part of a choice. That's actually true in 1.1 as well. But what are you actually trying to achieve? You've got a choice with only one branch, which is obviously redundant, except that it specifies...

finding file in root of wpf application

c#,xml,wpf,visual-studio,relative-path

First, ensure that the file is definitely copied into your output ./bin/ directory on compile: This worked perfectly for me in my WPF application: const string imagePath = @"pack://application:,,,/Test.txt"; StreamResourceInfo imageInfo = Application.GetResourceStream(new Uri(imagePath)); byte[] imageBytes = ReadFully(imageInfo.Stream); If you want to read it as binary (e.g. read an image...

Change attribute value of an XML tag in Qt

c++,xml,qt

I guess, but I think your XML is only present in your memory. You have to trigger somethink like tsFileXml.WriteToFile(filename) to store your changes to a file on your filesystem.

Fixed element in android?

android,xml,android-fragments

You need a FrameLayout. In a FrameLayout, the children are overlapped on top of each other with the last child being at the topmost. activity_main.xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"...

How to extract efficientely content from an xml with python?

python,xml,python-2.7,pandas,lxml

There are several things wrong here. (Asking questions on selecting a library is against the rules here, so I'm ignoring that part of the question). You need to pass in a file handle, not a file name. That is: y = BeautifulSoup(open(x)) You need to tell BeautifulSoup that it's dealing...

xml.etree.ElementTree.Element.remove not removing all elements

python,xml,elementtree

This demonstrates the problem: >>> root = ET.fromstring("<a><b /><c><d /></c></a>") >>> for e in root: ... print(e) ... <Element 'b' at 0x7f76c6d6cd18> <Element 'c' at 0x7f76c6d6cd68> >>> for e in root: ... print(e) ... root.remove(e) ... <Element 'b' at 0x7f76c6d6cd18> So, modifying the object that you are iterating affects the...

tcl tdom parsing failed due to special charecters in xml tags

xml,tcl,tdom

If you mean the ampersand, it is not in a tag, it is in the text that appears between two tags. The reason people choose to use XML for data interchange is that it's a standard, and there's lots of software around to handle it. That advantage disappears entirely if...

XSLT How to remove style from div and td tags

xml,xslt

To remove some nodes start with the identity transformation template <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> then add an empty template for the nodes to be removed: <xsl:template xmlns:xhtml="http://www.w3.org/1999/xhtml" match="xhtml:div/@style | xhtml:li/@style | xhtml:td/@style | xhtml:span/@style"/> ...

Load XML to list using LINQ [duplicate]

c#,xml,linq

Make a base class which will have id,x,y,z, and have Vendors,Bankers and Hospitals extend it. Then you can have a collection of the base class, and add to it the classes that inherit from it....

XML Schema 1.0 “All” with multiple same elements?

xml,schema

You're blocked by a non-orthogonality of XML Schema. You'd think that the following should work: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="top"> <xs:complexType> <xs:sequence> <xs:all> <xs:element name="A" minOccurs="0"/> <xs:element name="B" minOccurs="0"/> <xs:element name="C" minOccurs="0"/> <xs:element name="D" minOccurs="0"/> </xs:all> <xs:element name="E" minOccurs="1"...

Clean and convert HTML to XML for BaseX

html,xml,converter,xquery,basex

BaseX has integration for TagSoup, which will convert HTML to well-formed XHTML. Most distributions of BaseX already bundle TagSoup, if you installed BaseX from a Linux repository, you might need to add it manually (for example, on Debian and Ubuntu it's called libtagsoup-java). Further details for different installation options are...

ImageView inside scrollview (Android)

android,xml

use android:fillViewport="true" for scroll view and change ImageView scale type to android:scaleType="fitXY" <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="bottom" > <ScrollView android:id="@+id/scroll" android:fillViewport="true" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView...

List view not returning to original state after clearing search

java,android,xml,android-activity,android-listfragment

You are operating on the original data instead of filtered data. You should maintain a reference to original data and use the filtered data for all other purposes. So that the original data is displayed when search is cleared. Replace all usages of mData with mFilteredData as below and only...

xpath query seem to be failing

xml,xpath

$str = '<root><Pages> <copyright>me inc. 2015,</copyright> <author>Me</author> <lastUpdate>2/1/1999</lastUpdate> <Home>--------------------</Home> <About>--------------------</About> <Contact>------------------</Contact> </Pages></root>'; $xml = simplexml_load_string($str); $result = $xml->xpath('//Pages/*[(name() = "Home") or following-sibling::Home]'); if ($result === false) { $this->parseError(); //To return xml Error code...

Split XML into multiple files using xslt on string length

xml,xslt,xslt-2.0

I only need the 2 files. legacy.xml (bookIds not 10 in length) & current.xml (bookIds with length of 10). Then I would suggest you do it this way: XSLT 2.0 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/books"> <books> <xsl:copy-of select="book[string-length(bookId)=10]" /> </books> <xsl:result-document href="file:/C:/devFiles/legacy.xml"> <books> <xsl:copy-of...