|
Hi,
I have a directory containing loads of xml files that change regularly. To generate a list of all the files in the directory i use this code:
Sub Page_Load(sender as Object, e as EventArgs)<br />
If Not Page.IsPostBack then<br />
Dim dirInfo as New DirectoryInfo(Server.MapPath(""))<br />
repeater.DataSource = dirInfo.GetFiles("*.xml")<br />
repeater.DataBind()<br />
End If<br />
End Sub
I then display this information in a asp repeater. Currently it lists the filename and size and when the document was last edited.
I wish to extend this concept to allow me to display the 'title' element of each xml file alongside the filename in my asp repeater. I know how to extract the 'title' from a static list of xml files by explicity binding to each one, but i dont know how to do this 'on the fly' with the xml files in my generated list. I hope that made relative sense to somebody.
Thanks alot.
Colm.
|
|
|
|
|
"<xsl:with-param name="Curnode" select="//RealTimeData/*[position()=count(//RealTimeData/MasterData)]" />"
Kindly explain the select clause ...particularly what does the * imply here
Please elaborate on the result of each step....
-- modified at 5:44 Thursday 14th September, 2006
|
|
|
|
|
* means zero or more occurences
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
I have, for example, a variable $title accepting value (a string with value "title") from a text box .
Then I want to use this string to make reference to an element when I try to use a template that accepts a parameter as a node set.
<xsl:call-template name="show-items">
<xsl:with-param name="text" select="$title"/>
</xsl:call-template>
My xml is like this
<book>
<lang>english</lang>
<title>XML Basics</title>
<content>
......
</content>
</book>
but it does not work. The title accepted in the template "show-items" is not "XML Basics" but "title".
Please help!!!!
|
|
|
|
|
What you want to do is pass parameter "text" in "show-items" template with value "XML Basics" in it???
Try
<xsl:with-param name="text" select="/book/title/text()"/>
|
|
|
|
|
I want to use like
<xsl:with-param name="title" select="/book/$title">
but it doesn't work. It is said that a node set is needed, while the value of $title is 'title' (a string) not the title element, the "//book/title" one, the child node element of the book.
All I have now is a string with the value is the name of that element, and I want to use this name, translate it into a real element and then use that element.
Can I do that?
|
|
|
|
|
how can i pass xml nodes from a web service to a client.. as i m doin it in the normal way the way we pass string but its giving a parser error and soap exception
rabia
|
|
|
|
|
I help a small structure below
<jokes>
<joke>
<cat>poem</cat>
<title>ABC</title>
<content>
...
</content>
</joke>
<joke>
<title>123</title>
<content>
...
</content>
</joke>
</jokes>
As you can see, the values for <cat> is "poem" and "normal", for example. But I would like to make it like, when the <cat>poem</cat> appears, it means, the joke is in poem. But if the <joke> does not have <cat> or it has a empty pair <cat></cat>, the type of that joke is considered to be "normal".
How can I check to see if a tag is empty or not present?
|
|
|
|
|
You can test for the presence of a tag with XPath by just writing the tag name: //joke/cat This selects all <joke> tags that have a child <cat> tag. This selects all <cat> tags that are children of a <joke> tag. To test the actual contents of the <cat> you'll need other XPath functions (I just know basic XPath so I don't know the functions by heart, check out the docs)
|
|
|
|
|
Michael Dunn wrote: You can test for the presence of a tag with XPath by just writing the tag name: //joke/cat This selects all <joke> tags that have a child <cat> tag.
No, that would select the "cat" elements not the "joke" elements.
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
I was thinking the right thing, but explained it backwards.
|
|
|
|
|
The response above is correct. You can also use the boolean XPath function to determine if a tag is there or not:
/jokes/joke[boolean(cat)] would select all the joke nodes that contain a cat child element
/jokes/joke[not(boolean(cat))] would select all the joke nodes that don't have a cat child element
Logifusion[ ^]
If not entertaining, write your Congressman.
|
|
|
|
|
u can also compare value for that by using a query using XPathNavigator
-- modified at 5:13 Wednesday 13th September, 2006
|
|
|
|
|
Hi I need to merge several versions of xml documents which contain different data. I can't just append one document to another, instead it need to substitute elements which are the same (meaning having same tag in a hierarchy). One file will have higher precedence than the other and would substitute the data of the other one if same tag. I think an example would explain better than words.
<?xml version="1.0"?>
<!-- Old version, low precedence -->
<movies>
<movie name="Snakes on a Plane">
<director>David Ellis</director>
<year>2006</year>
<rating>M</rating>
</movie>
<movie name="The Descent">
<rating>R</rating>
<year>2005</year>
<director>Neil Marshall</director>
</movie>
</movies>
<?xml version="1.0"?>
<!-- Newer version, higher precedence -->
<movies>
<movie name="Snakes on a Plane">
<director>David R. Ellis</director>
<country>USA</country>
<rating>R</rating>
</movie>
<movie name="Finding Nemo">
<rating>G</rating>
<year>2003</year>
<director>Andrew Stanton</director>
</movie>
</movies>
<?xml version="1.0"?>
<!-- Merged version -->
<movies>
<movie name="Snakes on a Plane">
<director>David R. Ellis</director>
<year>2006</year>
<rating>R</rating>
<country>USA</country>
</movie>
<movie name="The Descent">
<rating>R</rating>
<year>2005</year>
<director>Neil Marshall</director>
</movie>
<movie name="Finding Nemo">
<rating>G</rating>
<year>2003</year>
<director>Andrew Stanton</director>
</movie>
</movies>
Notice in the merged version that for example director for Snakes on a Plane been updated and country added to same movie. Is there any way to do this using standard tools, like C#/.NET or SQLServer 2005 or some other library/product? Or do I need to implement this myself? Thanks for any pointers, Patric
/Patric
My C# blog: C# Coach
|
|
|
|
|
Patric_J wrote: I need to merge several versions of xml documents which contain different data.
Patric_J wrote: using standard tools, like C#/.NET
One way to manupulate XML in this fashion would be to use the System.XML.XmlDocument and the XML DOM that it represents. There is information everywhere about using XML DOM. It comes in real handy so you may as well bite the bullet and get familiar with it.
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
can anybody help? I don't know how to do that!
|
|
|
|
|
Hi,
I have the following code:
public class Item
{
private string name;
private int id;
[XmlElementAttribute]
public string Name
{
get{return name;}
set{name=value;}
}
[XmlElementAttribute]
public int ID
{
get{return id;}
set{id=value;}
}
}
I need to serialize an ArrayList of these Item(s).
public class Dummy
{
[XmlElementAttribute(typeof(Item))]
private ArrayList list;
public Dummy()
{
list=new ArrayList();
list.Add(new Item("one",1));
list.Add(new Item("two",2));
}
//this is called by a class that instantiates Dummy
public void save()
{
XmlSerializer ser=new XmlSerializer(typeof(Item));
StreamWriter writer=new StreamWriter("file.xml");
ser.Serialize(writer,list);
writer.Close();
}
}
but this won't work. Can anyone offer any suggestions?
thanx
|
|
|
|
|
Either make the list field public or make a read/write property for it. Xml serialization will not work on private fields. The reason for this is that the XmlSerializer builds some dynamic types to perform serialization instead of doing it by reflection. This puts the serialization outside of your namespace and it only has access to what is public. Which is also why you need a public default constructor. You also need to use the XmlArrayAttribute:
[XmlArray]
[XmlArrayItem(typeof(Item))]
public ArrayList list;
Logifusion[ ^]
If not entertaining, write your Congressman.
|
|
|
|
|
Hi everyone,
I want to using xmldom but i dont have microsoft.xmldom in my computer can you give me a site that i can download it.
Thanks
|
|
|
|
|
|
Thanks mike but which?theres many title?
|
|
|
|
|
I need to store some Key/Value pairs associated with a value(id) in a XML file.The xml file would have the following structure :
<language id=1>
<key1>value</key1>
<key2>value</key2>
<key3>value</key3>
.
.
.
</language>
<language id=2>
<key1>value</key1>
<key2>value</key2>
<key3>value</key3>
.
.
.
</language>
.
.
.
My question is How I can save and retrieve information to and from the document.Show me the full code please.
Because I may have more than one xml file of this type that each store different key/value pairs,I need a class that encapsulate everything.I mean it takes as an argument the file name and language "id" and then retrieve all key/value pairs associated with that "id" and we can access them using the class properties.Show me the attributes,methods... the class should have,the data types the class should use.(e.g. IEnumerable ...)
I need to use this in a multi-language website for storing static contents for different languages. I need it soon. Help me please !
Thanks
-- modified at 10:18 Friday 8th September, 2006
|
|
|
|
|
Deserializing into a dictionary is not an automatic thing, so you'd have to do this custom. Nobody's going to give you the "full code" for it though. You have to try writing it yourself and post something when you get stuck. But, after reading this statement:
devboycpp wrote: I need to use this in a multi-language website for storing static contents for different languages.
I'm curious why you're doing this in XML. The internationalization capabilities in .NET are very good. You can create a resx file that works in the same way for this key/value pair idea. It can localize strings based on language and region and it uses the current regional settings from the user. Using the built-in stuff, you can automatically adjust date/time, currency, and number formats to match the current region. There are all kinds of articles on CP and elsewhere describing how to do this.
Logifusion[ ^]
If not entertaining, write your Congressman.
|
|
|
|
|
Does internationalization capabilities in .NET let the user add new languages ?
My site is going to let site adminitrators add new languages(unlimited).Does the .NET built-in feature let me do this ?
|
|
|
|