xml

How can I parse XML to get multiple text blocks with SimpleXML?

I want to parse some XML that looks like this: <node> This is <child> blah </child> some <child> foo </child> text </node> How do I get access to the text node children in Simple XML? Can I access them in the correct order of text and element children? Do I need some other package for this? ...

Infinite loop while traversing XML in Actionscript 3

Hello, I've narrowed down the code to this (ignore the colourization): var theXML:XML = <xml> word </xml>; for each (var i:XML in theXML.*) { trace(i); } For some reason, this prints out "word" over and over indefinitely. Any thoughts as to why? I'm a bit out of practice and have a feeling it's something obvious...

Is there an equivalent to MS SQL 'FOR XML PATH' in other database products?

I am currently using Microsoft's FOR XML PATH feature to pull data back from MS SQL Server in an XML format. I really like the feature but am always uncomfortable about using vendor specific functions. Do any of the other major database vendors have something similar? Edit Let me be more specific with type of features I'm looking for...

Are XHTML entity encodings valid in XML documents as long as they're contained inside CDATA tags?

Is this a valid (well-formed) XML document? <?xml version="1.0" encoding="UTF-8" ?> <outer> <inner>&copy;</inner> </outer> At issue is whether the HTML/XHTML "" entity encoding is valid in an XML document where there is no DTD or schema to define it. An alternative way of expressing the above would be to say this: <?xml version="1...

XML Serialization - Missing Namespace Prefix at client end

I have created a .NET web service that returns an object, say Class "getResponse". The WS returns the following response ... <getResponse xmlns="http://tempuri.org/getCustomer/wsdl/"&gt; <Result xmlns="http://tempuri.org/getCustomer/"&gt; <ResultCode>OK</ResultCode> <ErrorsList/> </Result> </getResponse> while th...

XmlSchema Whitespace collapse: What happens to multiple whitespaces?

I use the following XmlSchema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.test.com/XmlValidation" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:m="http://www.test.com/XmlValidation"&gt; <xs:element name="test"> <xs:com...

How can I add a new property in an already existing xml file?

Hi, I am working on an application that parses a .csproj file. It needs to add an additional value to the <NoWarn> property if it exists. In the event that the property does not exist I want the application to add this property with its value to the specified parent node. How can I achieve this? I am using LINQ-to-XML to parse the proj...

How do I generate a comma-separated list with XSLT/XPath?

Given this XML data: <root> <item>apple</item> <item>orange</item> <item>banana</item> </root> I can use this XSLT markup: ... <xsl:for-each select="root/item"> <xsl:value-of select="."/>, </xsl:for-each> ... to get this result: apple, orange, banana, but how do I produce a list where the last comma is not present? ...

What namespace should I use for an XML schema?

I'm developing a custom XML schema for communicating data between application components. What do the SO folks consider a good (or, ideally, best) practice for selecting the URI for the namespace? Why? Some basic consideration: Our product has many components, and it's probably a good idea if the namespace indicates which component w...

Best method to populate XML from SQL query in ASP.NET?

I need to create a service that will return XML containing data from the database. So I am thinking about using an ASHX that will accept things like date range and POST an XML file back. I have dealt with pages pulling data from SQL Server and populating into a datagrid for visual display but never into XML for delivery, what is the best...

Crunching xml with python

I need to remove white spaces between xml tags, e.g. if the original xml looks like: <node1> <node2> <node3>foo</node3> </node2> </node1> I'd like the end-result to be crunched down to single line: <node1><node2><node3>foo</node3></node2></node1> Please note that I will not have control over the xml structure, so th...

Serializing a list of strongly typed objects

I might have messed up on a design decision. Instead of using a strongly typed collection of custom objects, I have used a generic List. Essentially, what i have is: public class AreaFields { [XmlArray("Items")] [XmlArrayItem("Item")] public List<Fields> Fields { set; get; } [XmlAttribute] int id { set; get; } } pu...

Can I validate an XPath expression against an XML schema?

You can verify an XPath expression against an XML doc to verify it, but is there an easy way to verify the same XPath expression against the schema for that document? Say I have an XSD schema like this: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" ... etc> <xsd:element name="RootData"> <xsd:complexType> <xsd:seq...

Is MSXML4 thread safe?

I would like to know if I create an instance of Msxml2.FreeThreadedDOMDocument.4.0 in one thread, can I safely manipulate the instance from different threads using raw pointers? ...

XML Versioning Algorithm

I'm looking for an efficient way to compare and get differences between two XML-based parse trees. What would you suggest to be the best way to store those differences? I would have done this: XML A: <w:p> <w:pPr> <w:spacing w:after="1"/> </w:pPr> <w:r> <w:t>World</w:t> </w:r> </w:p> XML B: <w:p> <w:pPr> <w:s...

XSLT Decimal formatting based on input XML.

I have a situation where my XSLT files should display prices alongwith decimals conditionally, depending on whether the input XML contains decimals or not. So, I can receive XML files with two types of values - XML will contain all prices formatted with decimals upto two places (I call this one "Decimal-XML") or the prices will be rounde...

UTF8, ISO-8859-x or 7-bit ASCII and entities

What's your opinion on encoding accented and special characters in XHTML and XML. Do you convert each and every non-US-ASCII character to named entity? You use ISO-8859-x or Win-125x and encode to entities anything else? Or do you directly write everything in UTF-8, without bothering about entities? Please elaborate on which and why...

LINQ to read XML (C#)

I got this XML file <root> <level1 name="A"> <level2 name="A1" /> <level2 name="A2" /> </level1> <level1 name="B"> <level2 name="B1" /> <level2 name="B2" /> </level1> <level1 name="C" /> </root> Could someone give me a C# code using LINQ, the simplest way to print this result: (Note the extra space if it is a level2 node)...

One XML Schema for Multiple but similar XML files

How can I create one XML Schema that will work with multiple but similar XML files. For instance, for a Food Recipes website I have a recipe XML called 'dessert' another 'indian' and another 'vegetarian', they are all pretty much the same, the only thing that changes is the root element. Here's an example of a file: <?xml version="1.0" ...

Storing results into a record trouble

Hi I am parsing an XML file and storing the results in a record, but am having some trouble. Im trying to store the results (content of my XML tags) into the fields of my record.. My record (at the moment there is only 1 set of XML elements). I think that the Parser.curconten is causing the problem... Type TXMLAlert=Record alert...