I'm passing small (2-10 KB)XML documents as input to a WCF service. now I've two option to read data values from incoming XML
Deserialize to a strongly typed object and use object properties to access values
use XPath to access values
which approach is faster? some statistics to support your answer would be great.
...
I'm regularly creating an XSD schema by transforming a proprietary data model of a legacy system. This works out pretty good. However, the legacy system only allows me to specify very basic attributes of a parameter, such as the data type (int, string etc.).
I would like to enhance the XSL transformation with a mechanism that allows me ...
I am working on an automated testing app, and am currently in the process of writing a function that compares values between two XML files that should be identical, but may not be. Here is a sample of the XML I'm trying to process:
<?xml version="1.0" encoding="utf-8"?>
<report xmlns="http://www.**.com/**">
<subreport name="RBDRep...
In .Net, I found this great library, HtmlAgilityPack that allows you to easily parse non-well-formed HTML using XPath. I've used this for a couple years in my .Net sites, but I've had to settle for more painful libraries for my Python, Ruby and other projects. Is anyone aware of similar libraries for other languages?
...
Can I use Xpath node set function position() in Delphi's function selectNodes() to select only a certain number of element from a node list? If I do like this:
selectNodes('Item[1]')
its all fine and I get the element with index 1, but when I try
selectNodes('Item[position()<10]')
I get exception 'unknown method', when I try
se...
I am testing against the following test document:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>hi there</title>
</head>
<body>
...
I'm trying to have an XSLT that copies most of the tags but removes empty "<b/>" tags. That is, it should copy as-is "<b> </b>" or "<b>toto</b>" but completely remove "<b/>".
I think the template would look like :
<xsl:template match="b">
<xsl:if test=".hasChildren()">
<xsl:element name="b">
<xsl:apply-templates/>
</xsl...
Hi there,
I am having trouble constructing a single XPath statement to return a set of attributes comprising of attributes of two or more different names.
For example take the following XML document:
<root>
<line name="one" alpha="a1" beta="b1"/>
<line name="two" alpha="a2" beta="b2"/>
<line name="three" alpha="a3" beta="b3"/>
</r...
I know this isn't really what XPath is for but if I have a HashMap of XPath expressions to values how would I go about building an XML document. I've found dom-4j's
DocumentHelper.makeElement(branch, xpath) except it is incapable of creating attributes or indexing. Surely a library exists that can do this?
Map xMap = new HashMap();
xM...
How can I verify a given xpath string is valid in C#/.NET?
I'm not sure just running the XPath and catching exceptions is a valid solution (putting aside the bile in my throat for a moment) - what if tomorrow I run into some other input I haven't tested against?
...
I know how to find what I need from XML using XPath. The syntax takes a little getting used to, but it is quite powerful. I'm interested in learning XQuery also, but the SQL like syntax seems awkward. Even so, if it can provide not just a select equivalent, but also update, insert, and delete as SQL does, I will forgive all awkwardnes...
How do I use XPathNavigator.Evaluate ( or other methods in XPathNavigator) to obtain the ISBN value for the following xml input?
<?xml version="1.0"?>
<!-- a fragment of a book store inventory database -->
<bookstore xmlns:bk="urn:samples">
<book genre="novel" publicationdate="1997" bk:ISBN="1-861001-57-8">
<title>Pride And Prejud...
What if I had a document that had multiple elements with the same name -- how would I retrieve, for instance, the second element?
<doc>
...
<element name="same">foo</element>
...
<element name="same">bar</element>
...
<element name="same">baz</element>
...
</doc>
I'd expect something like //elem[@name='same'][2] to work.
Additiona...
If I have several Section elements in an XML document, what XQuery do I use to get a list of all the name values?
<Section name="New Clients" filePath="XNEWCUST.TXT" skipSection="False">
...
Is there a way to find a node matched on part of a value.
If I have the following:
<competition id="100" name="Barclays Premier League"/>
<competition id="101" name="CocaCola Championship" />
<competition id="102" name="CocaCola League 1" />
Given the string "Premier League" or even "Prem", how would I match the correct node and get ...
Hello, everyone:
I am writing a xslt style sheet to transform a xml to another xml.
Here is the simplified version of original xml:
<eml>
<datatable>
<physical>
<distribution id="100"/>
</physical>
</datatable>
<software>
<implem...
What is the XPath expression that I would use to get the string following 'HarryPotter:' for each book.
ie. Given this XML:
<bookstore>
<book>
HarryPotter:Chamber of Secrets
</book>
<book>
HarryPotter:Prisoners in Azkabahn
</book>
</bookstore>
I would get back:
Chamber of Secrets
Prisoners in Azkabahn
I have tried something ...
Hi,
Can anyone tell me how can I get the xpath of the name attribute from this file:
<asmv1:assembly xmlns:asmv1="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="MyName"/>
</asmv1:assembly>
I'm trying to get it for nant xmlpoke task without success.
Thanks.
...
I have a XML with a structure similar to this:
<category>
<subCategoryList>
<category>
</category>
<category>
<!--and so on -->
</category>
</subCategoryList>
</category>
I have a Category class that has a subcategory list (List<Category>). I'm trying to parse this XML file with XPath, but I can...
I have a XML Structure that looks like this.
<sales>
<item name="Games" sku="MIC28306200" iCat="28"
sTime="11/26/2008 8:41:12 AM"
price="1.00" desc="Item Name" />
<item name="Games" sku="MIC28307100" iCat="28"
sTime="11/26/2008 8:42:12 AM"
price="1.00" desc="Item Name" />
...
</sales>
I am trying to find a ...