|
I have little problem. I am getting information from RSS with Xpath from xmldoc loaded from stream. Now i have problem with one node which innerxml looks like this:
<description>A Greek bank Thursday condemned the killings of three of its employees a day earlier as protesters geared up to return to the streets. Protesters object to a government plan that includes wage freezes and higher taxes.<img src="http://feeds.feedburner.com/~r/rss/edition_world/~4/_MQI3aBvO64" height="1" width="1"/></description>
How could i delete text from img src or retrieve it seperately to show image too?
|
|
|
|
|
I suspect that node can be HTML, or HTML-like? In which case, you need to parse that text as HTML so you can manipulate it...
It would help if you supplied more context, i.e. some XML which indicates what nodes of the RSS specification you are referring to exactly...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hi programmers, i have this task that has been troubling me due to my limited knowledge of XML/XSLT.
My task is to create an XSLT(dictionary.xslt) file that will use an XML(translation.xml) file as input which in turn will generate a desired HTML(dictionary.html) file like the one below.
- The index must be sorted alphabetically. This index serves as a Table Of Contents which allows users to browse through all 'initials' available in this dictionary.
- For each 'initial', the correct number of 'search' terms must be returned.
-
I will be able to do the css styling but as for the xslt code and functions i have little clue, i'd appreciate if someone here with the knowledge will be able to help me with this.
--- input XML (translation.xml) -----
<?xml version="1.0" encoding="UTF-8"?>
<Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="translation.xsd">
<from>EN</from>
<to>ES</to>
<total>150</total>
<translation initial="A">
<search>A Clockwork Orange</search>
<counter>1</counter>
<replace>La naranja mecánica</replace>
</translation>
<translation initial="A">
<search>A Few Good Men</search>
<counter>1</counter>
<replace>A Few Good Men</replace>
</translation>
<translation initial="A">
<search>A Star Is Born</search>
<counter>1</counter>
<replace>Ha nacido una estrella</replace>
</translation>
<translation initial="A">
<search>Ab Urbe condita</search>
<counter>1</counter>
<replace>Ab Urbe condita libri</replace>
</translation>
<translation initial="A">
<search>Ab urbe condita</search>
<counter>1</counter>
<replace>Ab urbe condita</replace>
</translation>
<translation initial="A">
<search>Abel</search>
<counter>2</counter>
<replace>Abel</replace>
<replace>Caín</replace>
</translation>
<translation initial="B">
<search>Batman & Robin</search>
<counter>1</counter>
<replace>Batman y Robin</replace>
</translation>
<translation initial="B">
<search>Bomarzo</search>
<counter>1</counter>
<replace>Bomarzo</replace>
etc......
..........
</translation>
--- DESIRED HTML OUTPUT ----
[url=http://img401.imageshack.us/i/resultf.jpg/][img]http://img401.imageshack.us/img401/5272/resultf.jpg[/img][/url]
---- WHAT I HAVE ATTEMPTED SO FAR ----
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<html>
<head>
<title>Bilingual Lexicon ES-EN</title>
<link href="dictionary.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>Browse by letter</h3>
</body>
</html>
</xsl:stylesheet>
|
|
|
|
|
 This does most of what you want...I've put in comments to show the different bits...
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<!-- We need a template matching the document root to start the transformation -->
<xsl:template match="/">
<html>
<head>
<title>Bilingual Lexicon ES-EN</title>
<link href="dictionary.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>Browse by letter</h3>
<table>
<!-- Process each translation element, sorted by the initial attribute and then the English term -->
<xsl:apply-templates select="//translation">
<xsl:sort select="@initial"/>
<xsl:sort select="search"/>
</xsl:apply-templates>
</table>
</body>
</html>
</xsl:template>
<!-- Template to process a translation element -->
<xsl:template match="translation">
<!--
If this is the first translation element, or its initial attribute is different
to the last one in the list of translation elements, output the
initial attribute.
-->
<xsl:if test="position()=1 or @initial != preceding-sibling::translation[1]/@initial">
<tr><td colspan="2"><h1><xsl:value-of select="@initial"/></h1></td></tr>
</xsl:if>
<!-- Output a row for each translation -->
<tr>
<td><xsl:value-of select="search"/></td>
<td>
<!-- Output the first replace element -->
<xsl:value-of select="replace[1]"/>
<!-- Output the other replace elements preceded by the separator -->
<xsl:for-each select="replace[position()>1]">
;<xsl:value-of select="."/>
</xsl:for-each>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hi,
I'm new to XML coding and I've got a problem I need help with. I'm developing a model in .gmax for FSX and I'm attempting to trigger animated objects using a switch that determines which animation to run. I know the following example isn't correct, I use this illustrate what I'm trying to do:
<PartInfo>
<Name>xyz_switch</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>
(L:xyz_01, bool) 100 *
(L:xyz_02, bool) 100 *
(L:xyz_03, bool) 100 *
(L:xyz_04, bool) 100 *
</Code>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<CallbackCode>
(L:xyz_01, bool) 0 > if{ (L:xyz_01, bool) 0 } els{ 1 }
(L:xyz_02, bool) 0 > if{ (L:xyz_01, bool) 0 } els{ 1 } <if xyz_01 is has already been activated, then run xyz_02>
(L:xyz_03, bool) 0 > if{ (L:xyz_02, bool) 0 } els{ 1 }<if xyz_01 and xyz_02 have already been activated, then run xyz_03>
(L:xyz_04, bool) 0 > if{ (L:xyz_03, bool) 0 } els{ 1 }<if xyz_01, 02 and 03 have been activated, then run xyz_04>
(L:xyz_05, bool) 0 > if{ (L:xyz_04, bool) 0 } els{ 1 }<if xyz_01,02,03 and 04 have been activated, then run xyz_05>
</CallbackCode>
</MouseRect>
</PartInfo>
Up to now, I've been trudging through and figuring out the code I've needed for new parts I'm creating, but this one's got me stumped!!
Can anyone give me a hand with this?
Thanks!!
AJ
|
|
|
|
|
So what are you having difficulties with?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
I need an expression that will cause the program to choose between 5 variables depending on which on is already active.
Example: There are five motors. I press a button to start motor #1. If motor #1 isn't already running, then it starts. If it is already running then the #2 motor starts. If #1 and #2 motors are already running, then #3 when will start, and so on.
That's all I'm trying to do really.
Thanks!
AJ
|
|
|
|
|
I don't understand how this relates to XML
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
The program I am developing for uses XML to compile and animate objects that are placed within a game. The expression I need is real simple, I just don't know how to "word" it in code.
|
|
|
|
|
You have done nothing to clarify your question. I still don't see how this is related to XML at all or what exactly you are trying to accomplish. Don't assume everyone is standing over your shoulder looking at the code you are working with. Explain what you are doing, what you have tried, what issues you are facing and what you need help with.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I need to write code for something other than what you guys use xml for, it's for a 3D modeling program.
Apparently I posted my question on the wrong forum.
Sorry guys, you have a nice day!
|
|
|
|
|
Hello, I got a simple question and i geuss the answer will be simple to. I've just spend 8 hours looking at this but can't seem to solve it.
I Got a gridview that shows data from an exsisting XML file. The user can select items the gridview with checkboxes.
When the user hits the next button the xml file should be updating the showimage attribute with "0" or "1" from the checkbox value of the gridview.
the XML is wellformed and has a schema.
basically it looks like this
root
itemcode
filename showimage=
etc
etc
/root
root
itemcode
filename showimage=
etc
etc
/root
root
itemcode
filename showimage=
etc
etc
/root
I have come as far as :
For Each row As GridViewRow In GrdImagesSel.Rows
Dim cbSi As CheckBox = row.FindControl("chkShowImage")
Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
Dim SiNodelist As XmlNodeList
Dim SiNode As XmlNode
SiNodelist = xmldoc.SelectNodes("docroot/root")
For Each SiNode In SiNodelist
Dim ShowImg = SiNode.ChildNodes.Item(1).InnerText
If ShowImg = productID Then Parentnode.Attributes("ShowImage").Value = cbSi.Text
Next
Next
that doesn't work.
Can you help me out here?
Regards,
Bram
|
|
|
|
|
One, without formatting the xml properly it's difficult to see your structure.
Axiom70m wrote: that doesn't work.
Two, you have to give a little more information than this. What doesn't work? Are you getting exceptions? Is it just not functioning?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
 Hi, Thanks for you message. Here's the XML file:
<AfasGetConnector>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AfasGetConnector">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="MNINT_Summary">
<xs:complexType>
<xs:sequence>
<xs:element name="Itemtype" type="xs:string" minOccurs="0" />
etc etc
<xs:element name="Afbeelding_in_Summary" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<MNINT_Summary>
<Itemtype>2</Itemtype>
<Itemcode>0401023100</Itemcode>
<Omschrijving>Tales Legends - The Erzberg</Omschrijving>
<Gewichtseenheid_code>3</Gewichtseenheid_code>
<Bruto_gewicht>16</Bruto_gewicht>
<Bestandsnaam ShowImage="">ERZBERGAVRV.JPG</Bestandsnaam>
<Artikelcode>3988</Artikelcode>
<Nominale_waarde>€ 10</Nominale_waarde>
<Jaartal>2010</Jaartal>
<Metaal>Silver</Metaal>
<Kwaliteit>Proof</Kwaliteit>
<Fijnheid>.925</Fijnheid>
<Diameter>32</Diameter>
<Mintage>40000</Mintage>
<Prijs_5>24</Prijs_5>
<Prijs_25>22</Prijs_25>
<Prijs_50>20.75</Prijs_50>
<Prijs_100>19.9</Prijs_100>
<Sold_Out>false</Sold_Out>
<Land>Austria</Land>
<Logo_mint>AUT</Logo_mint>
<Gewijzigd_op>2010-03-10</Gewijzigd_op>
<Aangemaakt_op>2009-10-06</Aangemaakt_op>
<Uitgifte_datum>2010-04-14</Uitgifte_datum>
<Opnemen_in_Summary>false</Opnemen_in_Summary>
<Afbeelding_in_Summary>true</Afbeelding_in_Summary>
</MNINT_Summary>
<MNINT_Summary>
<Itemtype>2</Itemtype>
<Itemcode>0401023400</Itemcode>
<Omschrijving>Tales Legends - The Erzberg</Omschrijving>
<Gewichtseenheid_code>3</Gewichtseenheid_code>
<Bruto_gewicht>16</Bruto_gewicht>
<Bestandsnaam ShowImage="">ERZBERGAVRV.JPG</Bestandsnaam>
<Artikelcode>3984</Artikelcode>
<Nominale_waarde>€ 10</Nominale_waarde>
<Jaartal>2010</Jaartal>
<Metaal>Silver</Metaal>
<Kwaliteit>Unc</Kwaliteit>
<Fijnheid>.925</Fijnheid>
<Diameter>32</Diameter>
<Mintage>130000</Mintage>
<Prijs_5>12.5</Prijs_5>
<Prijs_25>11.75</Prijs_25>
<Prijs_50>11.25</Prijs_50>
<Prijs_100>11</Prijs_100>
<Sold_Out>false</Sold_Out>
<Land>Austria</Land>
<Logo_mint>AUT</Logo_mint>
<Gewijzigd_op>2010-03-10</Gewijzigd_op>
<Aangemaakt_op>2009-10-06</Aangemaakt_op>
<Uitgifte_datum>2010-04-14</Uitgifte_datum>
<Opnemen_in_Summary>false</Opnemen_in_Summary>
<Afbeelding_in_Summary>true</Afbeelding_in_Summary>
</MNINT_Summary>
<MNINT_Summary>
<Itemtype>2</Itemtype>
<Itemcode>0401024300</Itemcode>
<Omschrijving>Renewable Energy NIOB</Omschrijving>
<Gewichtseenheid_code>3</Gewichtseenheid_code>
<Bruto_gewicht>9.1</Bruto_gewicht>
<Bestandsnaam ShowImage="">25EErneuerbareEnergieAVRV.JPG</Bestandsnaam>
<Artikelcode>3983</Artikelcode>
<Nominale_waarde>25 €</Nominale_waarde>
<Jaartal>2010</Jaartal>
<Metaal>Silver</Metaal>
<Kwaliteit>B.U.</Kwaliteit>
<Fijnheid>.9</Fijnheid>
<Diameter>34</Diameter>
<Mintage>65000</Mintage>
<Prijs_5>44</Prijs_5>
<Prijs_25>42.25</Prijs_25>
<Prijs_50>40.5</Prijs_50>
<Prijs_100>39.5</Prijs_100>
<Sold_Out>false</Sold_Out>
<Land>Austria</Land>
<Logo_mint>AUT</Logo_mint>
<Gewijzigd_op>2010-02-03</Gewijzigd_op>
<Aangemaakt_op>2009-10-06</Aangemaakt_op>
<Uitgifte_datum>2010-03-10</Uitgifte_datum>
<Opnemen_in_Summary>false</Opnemen_in_Summary>
<Afbeelding_in_Summary>true</Afbeelding_in_Summary>
</MNINT_Summary>
</AfasGetConnector>
I've added an atribute ShowImage in this file. The value should be added based on the gridview's checkboxes.
I don't get errors, it happens that only the last attribute gets a value or none at all.
I get stuck with looping through the gridview checkboxes and the itemcodes in the xml to get the right checkbox value with the right attribute...
This is what I've done so far...
For Each row As GridViewRow In GrdImagesSel.Rows
Dim cbSi As CheckBox = row.FindControl("chkShowImage")
'add the Itemcode to the row index
Dim productID As String = Convert.ToString(GrdImagesSel.DataKe(row.RowIndex).Value)
There should be some code that matches the productID to the itemcode in the XMLfile and if it matches add the value of the checkbox...
Thanks
modified on Tuesday, April 27, 2010 2:03 PM
|
|
|
|
|
Based on this schema your XPath expression would be "AfasGetConnector/MNINT_Summary[Itemcode=productID]"
XmlNode node = doc.SelectSingleNode("AfasGetConnector/MNINT_Summary[Itemcode=productID]");
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for your input, I realy appriciate it.
I'm still not sure how to make this work... How do I set the checkbox value in the ShowImage attribute XML?
Now only the last ShowImage attribute in the X<l gets="" a="" value="" and="" the="" other="" ones="" stay="" empty:
<pre="">
For Each row As GridViewRow In GrdImagesSel.Rows
Dim cbSi As CheckBox = row.FindControl("chkShowImage")
Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
Dim SiNode As XmlNode
SiNode = xmldoc.SelectSingleNode("AfasGetConnector/MNINT_Summary[Itemcode=productID]")
For Each SiNode In xmldoc
Parentnode.Attributes("ShowImage").Value = ("1")
Next
Next
Thank for reading
modified on Wednesday, April 28, 2010 4:13 AM
|
|
|
|
|
Please stop what you are doing and read the documentation for XmlDocument and related objects.
You can not use for/each on SiNode. SelectSingleNode Care to guess how many nodes this will return?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
That was not the smartest thing to do. I am totally lost here and getting a bit obsessed with this.
I can't figure out how I should do this, i thought it would be easier this way. If you can give me any clue it would be very much appreciated. Thanks for your replies and time.
Regards,
Bram
|
|
|
|
|
 Thanks for the help, i solved the problem
For Each row As GridViewRow In GrdImagesSel.Rows
Dim cbSi As CheckBox = row.FindControl("chkShowImage")
'Koppel Itemcode van de row aan productID en
If cbSi IsNot Nothing AndAlso cbSi.Checked Then
Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
Dim root As XmlNode = xmldoc.DocumentElement
Dim nodeList As XmlNodeList = root.SelectNodes("MNINT_Summary/Itemcode")
For Each productNode As XmlNode In nodeList
If productNode.FirstChild.InnerText = productID Then
Dim ShowImage As XmlElement = xmldoc.CreateElement("ShowImage")
productNode.AppendChild(ShowImage)
ShowImage.InnerText = "1"
End If
Next
Else
Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
Dim root As XmlNode = xmldoc.DocumentElement
Dim nodeList As XmlNodeList = root.SelectNodes("MNINT_Summary/Itemcode")
For Each productNode As XmlNode In nodeList
If productNode.FirstChild.InnerText = productID Then
Dim ShowImage As XmlElement = xmldoc.CreateElement("ShowImage")
productNode.AppendChild(ShowImage)
ShowImage.InnerText = "0"
End If
Next
End If
Next
|
|
|
|
|
Hi,
I hope I'm on the right forum.
My question is: how to create sitemap.xml file for your website? Is there any software? I see a lot of webmasters talking about how important is to have sitemap.xml.
Thanks!
|
|
|
|
|
|
|
Hi All,
I have some XML files which contains nodes word formatting nodes e.g..
w:pPr,w:r,w:t .
I want to see this XML file without word formatting.
Which tool or what setting i need to change to view this file without word formatting.
Thanks in Advance.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Hello Coders,
Im facing a problem building a C#.net code that will build me the following XML page:
<?xml version="1.0"?>
<chores>
<day title="some title">
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
</day>
<day title="some title">
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
</day>
<day title="some title">
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
</day>
</chores>
I've tried hundreds of codes, nothing worked the way i need it. i will appreciate any help PLEASE.
What im trying to do is the following:
I have a page that has 4 textboxes, each one is supposed to save some value .. lets say a,b,c,d..
Another textbox is for the day attribute which is TITLE according to my example
I need to add whenever i need a DAY. with it's attribute. and "jobs" like that example.
whenever i need to make a new "DAY" i need it do be after the last one. i mean i need it to update the new <DAY> after the last one's
and all of that i need it to come before the each time i update the xml file</chores>
Please i'd really appreciate any help with this. im new to XML and im trying to make an XML management page for some project.If what i've said wasnt clear im ready to explain again. Please tell me what to do and how to do it, or if you have any samples for handling such an issue it will be great too
|
|
|
|
|
Can you show us a little of what you tried?
What you are trying to do is maintaining a kind of database.
On the assumption that you really want it as xml-file :
option 1 : Read your file as XmlDocument and add nodes as you add entries.
option 2 : Create a dedicated class model with serializing/deserializing.
Both methods have as disadvantage that everything get loaded in memory. To prevent that you might have to split your model in multiple files.
Google for XmlDocument and/or XSD utility.
If you need further clarification, just ask.
|
|
|
|