|
Hello,
My application receives XML files from users submitted via web. It then reads and loads them in the SQL Server database using a C# routine. The file sizes are like 2/3 megabytes. The web validation (XML schema and other checks like existence of valid data ids etc.) takes long - sometimes 30 sec to 1 min.
What would be a better way to improve performance - possibly not using this C# parser?
I would highly appreciate ideas.
Thanks.
|
|
|
|
|
|
Thanks Mike. It'll be helpful.
|
|
|
|
|
Hello,
I'm using C# 2008 to create XML files where some elements have null text values, as shown in the following code.
nodeUnderTest.InnerText = "";
The problem is that the end tag is being placed on the following line, as shown below where nodeUnderTest is <test>:
<pre><something>
<test>
</test>
</something></pre>
Using C#, how can I force the start and end XML tags to either appear on the same line or merged as shown below?
<test></test>
<test />
Thanks,
Grant
modified on Monday, April 20, 2009 4:01 PM
<div class="ForumMod">modified on Monday, April 20, 2009 4:03 PM</div>
|
|
|
|
|
Don't set the nodeUnderTest.InnerText at all. Just create the element. Also, nodeUnderTest.InnerText=""; is being set to an empty string and not a null value.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
When I set nodeUnderTest.InnerText = null, the start and end tags were once again placed on separate lines.
When I commented out the nodeUnderTest.InnerText line, it placed the tags on the same line, but they were separated by a single space.
I still need to determine how to either force the tags to be appear on the same line with no space in between or as the shortened version <test /> where the start and end tags are inclusive.
Thanks.
|
|
|
|
|
Post some code to show what you are doing.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I have an application that displays a treeview with the following structure:
+ TreeRoot
+-+ Heading
| +-+ DataElement
| +-+ DataElement
| +-+ Heading
| +-+ DataElement
| +-+ DataElement
+-+ Heading
| +-+ DataElement
. . .
Note the data order is important and must be preserved.
I have stored this in a XML file like this.
<root>
<heading>
<dataelement>First data<\ DataElement>
<dataelement>Second data<\ DateElement>
<heading>
<dataelement>First nested data<\ DataElement>
<dataelement>Second nested data<\ DataElement>
<\ heading>
<\heading>
<heading>
<dataelement>data<\DataElement>
<\heading>
. . .
<\root>
I am able to read and writhe this data to and from the tree and update the xml file.
However I am not able to describe this structure in a Schema.
Is there a method that would be univerally portable to keep this structure.
I would prefer not to use H1, H2, H3 . . . method for the nested headers.
Thanks for the help.
|
|
|
|
|
let say I have this:
<books>
<book>
<title genre="non-fiction">Objects First With Java- A Practical Introduction Using Bluej </title>
<author>David J. Barnes</author>
<author>Michael Kolling</author>
<publisher>Pearson Prentice Hall</publisher>
<year>2006</year>
<price>49</price>
</book>
<book>
<title genre="fiction">Harry Potter and the Half-Blood Prince</title>
<author>J. K. Rowling</author>
<publisher>Thorndike Press</publisher>
<year>2005</year>
<price>29</price>
</book>
</books>
and I want to sum the price if the title genre is fiction and book price is less than 30 (I should have more books for this but will add later).
currently I read somewhere I came up with this:
<xsl:value-of select="sum(/books/book/title[@genre='fiction']/price[number(text())<30])" />
or this:
<xsl:value-of select="sum(/books/book[title[@genre='fiction']]/price[number(text())<30])" />
but it seems I still cant get it right. Anyone could help where I did wrong?
Edited:
I found the problem that I should use '& lt;30' instead of <30. I believe I did use lt before asking.
Anyway, why the< b r / > in my xsl file does not work in FireFox but it is fine with IE?
Many thanks.
modified on Friday, April 17, 2009 8:28 AM
|
|
|
|
|
You were almost there with your second effort:
sum(/books/book[title[@genre = 'fiction']]/price[. < 30])
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Using dot .& lt;30 seems to be working too and less confusing instead of number(text()).
Thanks for your reply.
|
|
|
|
|
Hello,
I'd like to make a project that has DOM support. I'm thinking of using Xerces. What I'd like too is to have a API to access the same DOM implementation both in C++ and JAVA..... I mean, some apps will use it through C++, others in Java, while the rest of the library will be C++. Is Xerces a good solution for that? As I see there are both Java and C++ bindings, will this help achieve what I need?
|
|
|
|
|
AFAIK the two Xerces (C++/Java) implementations are completely separate. It sounds like you have read something that says they are one implementation, could you supply a link to that?
gotchagotcha wrote: What I'd like too is to have a API to access the same DOM implementation both in C++ and JAVA
Why? The whole point is that the DOM is the standard and therefore the API's are mostly identical. Designing your applications with a DAL probably provides a much larger benefit than sharing a DOM implementation.
Also to use native code from Java requires the use of JNI so you can't directly utilize a C++ anything by writing pure Java code. Anyway if you are bent on doing this I suppose you could provide the JNI wrappers for the C++ Xerces DOM. It seems pointless to me but whatever.
|
|
|
|
|
Hi All,
I am writing the following code
"<a href="{@FileRef}" > <xsl:value-of select="@Title" />
</a>"
The problem is that my "FileRef" contains special character in it (like test's.aspx, the single quotes in it).In the browser the URL is shown as
test's.aspx.
Is there any work around for this.
I don't know how to handle the unsafe character in xslt.
Thanks in Advance
Alok....
modified on Wednesday, April 15, 2009 10:39 AM
<div class="ForumMod">modified on Wednesday, April 15, 2009 10:43 AM</div>
|
|
|
|
|
IMHO, I would avoid using "special" characters and white space in a URL since it always gets URL-encoded. In your case, the single quote will be change to %28 . Besides, since XSLT is really XML, you can use " instead of ' . Please note that you can place characters such as a single quote in CDATA sections!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
please help me....
how can i convert data set to xml according to my DTD
R RajaGuru
|
|
|
|
|
Do you know what a DTD is, and why do you need to use one? If you have the answers to these questions, you should know what to do.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
|
hi all
This is to read the tag line by line.
using System.Xml;
...
...
...
XmlTextReader reader = new XmlTextReader ("reader.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + reader.Name);
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine (reader.Value);
break;
case XmlNodeType.EndElement: //Display the end of the element.
Console.Write("</" + reader.Name);
Console.WriteLine(">");
break;
}
}
Console.ReadLine();
How do i read the specific tag
if i just want to read all the tag that have this < big > tag?
thank you
|
|
|
|
|
This might help you get started:
reader.ReadToFollowing("big");
do
{
} while (reader.ReadToNextSibling("big"));
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
You can use XPath to simplify your work. For example:
XmlDataDocument xmlDoc = new XmlDataDocument();
xmlDoc.Load("yourfile.xml");
XmlNodeList xmlNodeList = xmlDoc.SelectNodes("roottag/big"); //XPath expression
More detail information pls. refer to Microsoft MSDN.
|
|
|
|
|
Unfortunately, our poster is using XmlTextReader . You don't use XPath with that.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi all,
Can you please let me know how to change the following XML so that i have HOME and SERVICES as parent node.At the moment HOME Contains SERVICES as a Sub Node.
What i want is When i click on Home the Service Link shouldnt be hidden.
<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
<siteMapNode title="Home" >
<siteMapNode title="Services" >
<siteMapNode title="Training" url="~/Training.aspx"/>
</siteMapNode>
</siteMapNode>
</siteMap>
Thank you In advance.
|
|
|
|
|
kibromg wrote: What i want is When i click on Home the Service Link shouldnt be hidden.
I don't know if anyone will understand your post, I know I don't. XML is text so when you click on it nothing is going to happen.
My guess is you left some stuff out of your post under the mistaken notion that we already know what you are thinking and doing, we don't, that's not really how internet forums work. Or perhaps you don't know anything about XML yourself. If that is the case try some of the tutorials at www.w3schools.com
|
|
|
|
|
I'm using an XMLDataSource to pull rss feeds into my site. Some of the feeds have really long descriptions, so I'd like to limit the length of the description fields, and then append a "..." to the end.
Is there any way to do that?
|
|
|
|