|
To return a collection (list) of nodes, you need to use the SelectNodes function. Using your example XML, to return all of the Category nodes, you need to use the following XPath query: //Category . This tells the parser to find all of the "Category" nodes that are one level below the root node.
|
|
|
|
|
Below is a sampling of my code. The code takes information from one program and list it all on an excel sheet. The problem is that the excel sheet is generic. Some of the information going into the excel sheet have different lengths of characters. How can i use this same code but instead of generating a generic excel sheet I could change the dircectory to point at a custom formatted excel sheet with all of the cells custom formatted.
thannks for any help.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Output Design List as an comma seperated (csv) file. -->
<xsl:output method="text" encoding="iso-8859-1"/>
<xsl:template match="DESIGNLIST">
<xsl:for-each select="DESIGN">
<xsl:if test="position()=1">
<xsl:call-template name="DesignData">
<xsl:with-param name="HeaderRow" select="1"/>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="DesignData">
<xsl:with-param name="HeaderRow" select="0"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- Process and output the child elements of the design element. -->
<xsl:template name="DesignData">
<xsl:param name="HeaderRow"/>
<!-- Output the index -->
<xsl:choose>
<xsl:when test="$HeaderRow>0"><xsl:text>item Number</xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="position()"/></xsl:otherwise>
</xsl:choose>
<!-- Output the columns -->
<xsl:if test="THUMBNAIL">
<xsl:choose>
<xsl:when test="$HeaderRow>0"><xsl:text>,Thumbnail</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>,</xsl:text><xsl:value-of select="THUMBNAIL"/></xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="NAME">
<xsl:choose>
<xsl:when test="$HeaderRow>0"><xsl:text>,Design#</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>,"</xsl:text><xsl:value-of select="NAME"/><xsl:text>"</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="REV">
<xsl:choose>
<xsl:when test="$HeaderRow>0"><xsl:text>,Rev</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>,</xsl:text><xsl:value-of select="REV"/></xsl:otherwise>
</xsl:choose>
|
|
|
|
|
Hi all,
Can anyone tell me How can we acheive RSS feed through ASP.net ?
Advance thanks
By Jegastar.
Exchanging the knowledge leads to wisdom.
|
|
|
|
|
We currently define the structure of flat file wthiin our organisation using fields stored in a database.
However i want to move to an xml file type definition to define file structure, maybe using some sort of schema file.
I've seen an article on the use of XFlat. Does anyone know if its any good or any other alternative 'best practice' solutions?
Regards
|
|
|
|
|
XFlat is an XML language for defining flat file schemas.
link[^]
Based on your post it sounds like you want to create XML files from your database so XFlat would be of no value to that effort.
What platform and development tools are you using?
Have you looked at any database/xml related articles here on code project?
|
|
|
|
|
I'm currently on XP using VB.NET 2005.
The organisation uses an older version of SAP which outputs flat files which need processing into other systems.
I've looked at xsd validation which is useful for validatiing xml files and will be useful when we eventually upgrade SAP.
However i need a generic way (or as much as possible) for reading from and creating flat files. I was wondering if there was a way of specifiying the structure of the flat files using xml files as some sort of schema.
If not, is it possible i could de-serialise the flat files, maybe into objects and then later serialise them to (possibly) a different structured files?
This is where i was wondering whether an xml type schema could be used.
Any help, greatly appreciated.
|
|
|
|
|
You can use XSLT to transform your flat files to XML.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
There are many different ways to go from flat file to XML and one is the XmlCsvReader[^]
|
|
|
|
|
There you go digging deep in the documentation again!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
zxc89 wrote: Using C++ code How to get the element values based on the index for the following example:
To start with your following example does not mention finding anything based on the index so your post makes no sense.
Next, what do you know about working with XML? If the answer is nothing then you better start reading. Depending on your requirements and other subtle aspects of your application you could either use a DOM and perform XPath queries or use a SAX parser. Both parsers provide access to the XML data in very different ways and you will have to know and understand these things to determine which is more appropriate for your solution.
|
|
|
|
|
am trying to inherits membership class and implementing IXmlSerializable but it doesn't work.
public class SSOMembershipUser : System.Web.Security.MembershipUser ,IXmlSerializable
'SSO.Security.SSOMembershipUser' does not implement interface member 'System.Xml.Serialization.IXmlSerializable.GetSchema()'
seema
|
|
|
|
|
Hi everyone,
I'm trying to compose an XML with serialization in VB.NET, but I'm having a problem with an array. What I'm looking for is to get something like this:
<root>
<item>item 1</item>
<item>item 2</item>
<item>item 3</item>
</root>
But if I use a XML array with code like this:
<Xml.Serialization.XmlArray(elementname:="Item")> _
Public Property Item() As List(Of Item)
Get
Return m_items
End Get
Set(ByVal value As List(Of Item))
m_items= value
End Set
End Property
What I get is something like this:
<root>
<Item>
<item>item 1</item>
<item>item 2</item>
<item>item 3</item>
</Item>
</root>
How should I do it in order to get the item elements right under the root and not indented inside <Item>? This is my first work with serialization and maybe I'm missing something stupid. I've been looking in some forums but I haven't found an answer to this.
Thanks in advance
|
|
|
|
|
Hi, as the title says, I have to deserialize an unknown object from an xhtml format... So, anybody has any idea suggestion how to make this work...?
|
|
|
|
|
Interperate any give XML and turn it into an object? Good luck with that, I don't see how it could be possible. Can you give more details on what you're trying to do?
|
|
|
|
|
Mogyi wrote: I have to deserialize an unknown object
I am not aware of any OO language that supports creating an object absent the type information.
|
|
|
|
|
Hi all,
I've got a small problem while designing a web-page. I am using a stylesheet .css to customize the appearance of my page. The stylesheet looks as follows:
.rightbar<br />
{<br />
background-color: #d2691e;<br />
color:whitesmoke;<br />
}<br />
.body <br />
{<br />
background-color: #d2691e;<br />
color:whitesmoke;<br />
font-family:Arial;<br />
font-style:italic;<br />
font-weight:200;<br />
}<br />
.body img <br />
{<br />
src:"Images/Chocolates/1.jpg";<br />
alt:"007";<br />
}<br />
.footer<br />
{<br />
background-color: #d2691e;<br />
color:whitesmoke;<br />
}
In my web page which is of type .ASPX, i've used the above stylesheet. All stuff is working fine except the ".body img" customization above. I've got a element which is given the class attribute as "body".
As the tag is right inside this element, so i think this customization should work. but its not working. The portion of HTML using this class is as follows:
<td class="body" style="width: 616px; text-align: left;"><br />
<br /><br />
<img id="img1" alt="1" src="" style="height: 177px; width: 442px;" align="middle"/> <br />
<br /><br />
<asp:contentplaceholder id="FlowerPicture" runat="server"><br />
</asp:contentplaceholder><br />
</td>
could you plz help me with this ?
when you want something, the universe conspires in helping you achieve it
|
|
|
|
|
prahlad1981 wrote: .body img
{
src:"Images/Chocolates/1.jpg";
alt:"007";
}
"src" an "alt" are not CSS1 or CSS2 properties.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George,
Thanks very much for your reply. I figured out that in ASP.Net there are better ways to change images on runtime (based on user preferences) than using stylesheets. However, the .Net XML Intellisense editor does show a property called src, but it works only for fonts and not for the img tag.
when you want something, the universe conspires in helping you achieve it
|
|
|
|
|
The "img" tag has "src" and "alt" attributes. That is what the intellisense is picking up. Also, ASP.NET 2.0 works well with CSS.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
My application has a class CUser which represents a user. The application serializes the user object to XML like this:
CUser aUser = new CUser("firstname", "surname", "address");
XmlSerializer serializer = new XmlSerializer(typeof(CUser));
StreamWriter streamWriter = new StreamWriter("user.xml");
serializer.Serialize(streamWriter, aUser);
streamWriter.Close();
I've been asked to have the user details encrypted so people can't casually look at the user details. From the above I'd like to encrypt the XML strings as they're written to the file but is there an easy way of doing it? It seems that it would be convenient to have the data encrypted by the StreamWriter and then decrypted by a StreamReader . I'll need a password so how do I manage that within the application?
Thanks
|
|
|
|
|
Hello. I'm newbie in working with xml files. I need to load a xml file to a datatable. First thing I saw is the dataset.ReadXml method, but I get an exception:
The same table (mSCAddress) cannot be the child table in two nested relations.
The nesting level is quite deep, and later I have to move throw the structure to create a datatable with some relevant data.
I don't know where to start.
Regards,
Diego F.
|
|
|
|
|
I detail a bit the file structure.
<file>
<record>
<composite>
<data>...</data>
<data>...</data>
</composite>
</record>
<recurd>
<data>...</data>
</record>
</file>
As you see, inside record section I have two posibilities. I can have just one data or a composite section, that contains more than one data sections.
Inside data, there are different possibilities also.
Is that structure a problem to load the file?
Regards,
Diego F.
|
|
|
|
|
Well, as I tested, the problem is having as a nested element inside <composite> and inside <record>
I can't change the file structure. Can you tell me other way to do that?
Regards,
Diego F.
|
|
|
|
|
Below is a sampling of my stylsheel code. When it exports the information to an excel page all of the columns are the same width. How can I customize each colum entry to conform to a custom column width?
thanks for the help.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="iso-8859-1">
<xsl:template match="DESIGNLIST">
<xsl:for-each select="DESIGN">
<xsl:if test="position()=1">
<xsl:call-template name="DesignData">
<xsl:with-param name="HeaderRow" select="1">
<xsl:call-template name="DesignData">
<xsl:with-param name="HeaderRow" select="0">
<xsl:template name="DesignData">
<xsl:param name="HeaderRow">
<xsl:choose>
<xsl:when test="$HeaderRow>0"><xsl:text>item Number
<xsl:otherwise><xsl:value-of select="position()">
<xsl:if test="THUMBNAIL">
<xsl:choose>
<xsl:when test="$HeaderRow>0"><xsl:text>,Thumbnail
<xsl:otherwise><xsl:text>,<xsl:value-of select="THUMBNAIL">
<xsl:if test="NAME">
<xsl:choose>
<xsl:when test="$HeaderRow>0"><xsl:text>,Design#
<xsl:otherwise><xsl:text>,"<xsl:value-of select="NAME"><xsl:text>"
<xsl:if test="REV">
<xsl:choose>
<xsl:when test="$HeaderRow>0"><xsl:text>,Rev
<xsl:otherwise><xsl:text>,<xsl:value-of select="REV">
<xsl:if test="RESOURCE">
<xsl:for-each select="RESOURCE">
<xsl:call-template name="ResourceData">
<xsl:with-param name="HeaderRow" select="$HeaderRow">
|
|
|
|
|
I suggest you turn off the html parsing when you post the code because it's simply disappeared.
|
|
|
|