|
Sorry For not mentioned the Macors
Sub sameoldcalvin()
'
' Macro3 Macro
'
Dim i As Long
Dim SearchRange As Range
Dim FindRow As Range
Dim pp As String
Range("G1").Select
Start:
Do
' Whole process loop counter = do it 9000 times
i = i + 1
ActiveCell.Offset(1, 0).Range("A1").Select
pp = ActiveCell.Value
Set SearchRange = Range("G:G")
Set FindRow = SearchRange.Find(pp, LookIn:=xlValues, lookat:=xlWhole)
If FindRow.Row = ActiveCell.Row Then
GoTo Start
Else
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveCell.Offset(0, 4).Range("A1:B1").Select
Selection.Cut
ActiveCell.Offset(-1, 0).Range("A1").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, -2).Range("A1").Select
'delete
ActiveCell.Rows("1:1").EntireRow.Select
ActiveCell.Activate
Selection.Delete Shift:=xlUp
ActiveCell.Offset(-1, 3).Range("A1").Select
End If
Loop Until i = 9000
End Sub
|
|
|
|
|
Hi,
My XML looks like <book>ABC,XYZ
In my coding I getting this using
XmlNodeList allNodes= XmlDoc.GetElementsByTagName("Book");
I am checking whether this any childnodes exists for this using
XmlNode child=allNodes[0].ChildNodes[0];
string Childname= child.Name;
I am getting this(childname as) "#text" ,though no childnode is there in my XML
|
|
|
|
|
Both your allNodes object and the ChildNodes property of allNodes is a XMLNodeList. Thus, both allNodes and ChildNodes have a Count property that you can check to verify if GetElementByTagName returned any nodes or if ChildNodes contains any nodes.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi all,
I am trying to save a list of products in a XML database. But, when I try to read the xml file (outputting goes ok, using the XMLTextWriter) I get an error message telling me that there are illegal characters in a name and that the document can't be read. What can I do about this? I am trying to save the products as follows: (I am using Visual Basic.NET - VS2005)
<code>
[Groupname]
[Brandname]
[Productname]
[Price]3,99[/Price]
[ItemID]12345[/ItemID]
[Description]""[/Description]
[/Productname]
[/Brandname]
[/Groupname]
</code>
And it is no option to not let people type special characters, since there are loads of brand- and productnames containing special characters (like é, ä, @ etc)
Please help me out,
--Zaegra--
Motivation is the key to software development.
modified on Thursday, September 11, 2008 12:50 PM
|
|
|
|
|
|
Hi All,
I have this XML document:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="WriteXMLToDBTest_SQLScript.xsl"?>
<OrderDetails>
<Order ID="10248">
<OrderItem ProductID="11">
<QuantityIncrease>2</QuantityIncrease>
</OrderItem>
</Order>
<NewOrder ID ="10249">
<OrderItem ProductID ="12">
<QuantityIncrease>3</QuantityIncrease>
</OrderItem>
</NewOrder>
</OrderDetails>
and have applied this XSL:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method ="text" encoding ="utf-8"/>
<xsl:output indent ="yes"/>
<xsl:template match ="/">
<xsl:apply-templates select ="OrderDetails/Order"/>
<xsl:apply-templates select ="OrderDetails/NewOrder"/>
</xsl:template>
<xsl:template match ="Order">
<xsl:text>Update [Order Details] Set Quantity = Quantity + </xsl:text>
<xsl:value-of select ="OrderItem/QuantityIncrease"/>
<xsl:text> Where OrderID = </xsl:text>
<xsl:value-of select ="@ID"/>
<xsl:text> And ProductID = </xsl:text>
<xsl:value-of select ="OrderItem/@ProductID"/>
</xsl:template>
<xsl:template match ="NewOrder">
<xsl:text>Update [Order Details] Set Quantity = Quantity + </xsl:text>
<xsl:value-of select ="OrderItem/QuantityIncrease"/>
<xsl:text> Where OrderID = </xsl:text>
<xsl:value-of select ="@ID"/>
<xsl:text> And ProductID = </xsl:text>
<xsl:value-of select ="OrderItem/@ProductID"/>
</xsl:template>
</xsl:stylesheet>
and it generates two sql statements:
Update [Order Details] Set Quantity = Quantity + 2 Where OrderID = 10248 And ProductID = 11Update [Order Details] Set Quantity = Quantity + 3 Where OrderID = 10249 And ProductID = 12
problems in here is that two "update statements" on the single line and i would like to know how to seperate them like this:
Update [Order Details] Set Quantity = Quantity + 2 Where OrderID = 10248 And ProductID = 11
Update [Order Details] Set Quantity = Quantity + 3 Where OrderID = 10249 And ProductID = 12
Thanks a lot
|
|
|
|
|
Do you realize that depending on the source of the XML you could be exposing your system to SQL Injection[^] attacks due to your antiquated technique of updating a database? Antiquated in this case means generating SQL statements.
led mike
|
|
|
|
|
ok, cool, i just realise this, thanks to mention that to me.
|
|
|
|
|
Hello,
I am trying to read the attached XML file by entering the <string code="????"> and return the value for <lang code="EN">Access Allowed List</lang>.
I have worked with reading simple XML elements but have not worked with atributes and the like. I am also new to both XML and Dev in general.
I have read several articles but most give me examples for reading simple XML e.g.
<person>
<firstname>John</firstname>
<lastname>Smith</lastname>
</person>
The file I am trying to read is below, any help would be great and examples are very much welcome. My goal for the GUI in VB.NET will be to have a textbox to enter string number I am searching for and a dropdown but to select the language.
Regards
Jason
<momlang>
<string code="2000">
<lang code="AR">Access Allowed List</lang>
<lang code="CZ">Access Allowed List</lang>
<lang code="DE">Access Allowed List</lang>
<lang code="DK">Access Allowed List</lang>
<lang code="EE">Access Allowed List</lang>
<lang code="EN">Access Allowed List</lang>
<lang code="ES">Lista de accesos permitidos</lang>
<lang code="FI">Pääsylista sallitut</lang>
<lang code="FR">Liste des accès autorisés</lang>
<lang code="GB">Access Allowed List</lang>
<lang code="HU">Hozzáférés Engedély Lista</lang>
<lang code="IT">Elenco accessi consentiti</lang>
<lang code="NL">Access Allowed List</lang>
<lang code="NO">Liste over systemtilgang</lang>
<lang code="PL">Access Allowed List</lang>
<lang code="RU">Access Allowed List</lang>
<lang code="SE">Använda tillåten lista</lang>
</string>
<string code="10000">
<lang code="AR">المطبوعة:</lang>
<lang code="CZ">Vytisknuto:</lang>
<lang code="DE">Gedruckt:</lang>
<lang code="DK">Printed:</lang>
<lang code="EE">Prinditud:</lang>
<lang code="EN">Printed:</lang>
<lang code="ES">Impreso:</lang>
<lang code="FI">Tulostettu:</lang>
<lang code="FR">Imprimé:</lang>
<lang code="GB">Printed:</lang>
<lang code="HU">Nyomtatott:</lang>
<lang code="IS">Printed:</lang>
<lang code="IT">Stampato:</lang>
<lang code="NL">Afgedrukt:</lang>
<lang code="NO">Skrevet ut</lang>
<lang code="PL">Wydrukowano:</lang>
<lang code="RU">Ðапечатано:</lang>
<lang code="SE">Utskrivet:</lang>
</string>
</momlang><pre></pre><pre></pre><pre></pre>
When people make you see red, be thankful your not colour blind.
modified on Thursday, September 11, 2008 8:47 AM
|
|
|
|
|
Hello,
OK I have worked out the below code to return the 'EN' string if I supply the string code, say "1000".
What I need to know is understand how to search for the string and return the string code. If I would use a wildcard in this it would be great.
Any Thoughts???
Private Sub XPathSearch(ByVal XMLPath As String)
Dim xmlNI As XPathNodeIterator
Dim xpathDoc As XPathDocument
Dim xmlNav As XPathNavigator
Try
xpathDoc = New XPathDocument(XMLPath)
xmlNav = xpathDoc.CreateNavigator()
xmlNI = xmlNav.Select("/MOMLANG/STRING[@code='" & stringValue & "']/LANG[@code='EN']")
While (xmlNI.MoveNext())
'Me.RichTextBox1.AppendText(xmlNI.Current.Name + " : " + xmlNI.Current.Value & vbCrLf)
Me.RichTextBox1.AppendText("String value: " + xmlNI.Current.Value & vbCrLf)
End While
Catch ex As XPathException
System.Console.WriteLine("XMLException: " + ex.Message)
Catch ex As Exception
System.Console.WriteLine("Exception: " + ex.Message)
End Try
End Sub
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
I have XML as well as its XSL, what is needed is to send this xml to email as html in body and i want to do it using Microsoft XML, v3.0 which comes with IE.
|
|
|
|
|
Do you have a question?
led mike
|
|
|
|
|
Yes, Actually I am working in Microsoft Dynamics NAV.
Here for using XML I can use 'Microsoft XML, v3.0'
and I have 1 xml, and 1 xsl given below
XSL:
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:template match="/">
- <html>
<head />
- <body style="FONT-FAMILY: Tahoma;">
- <table border="0" width="100%">
- <!-- Main Table
-->
- <tr>
- <!-- The only row of main table
-->
- <!-- For Image
-->
- <table>
- <tr>
<img src="1.jpg" />
</tr>
</table>
<br />
- <!-- End For Image
-->
- <h3>
Dear
<xsl:value-of select="CUSTHTLVOUCHER/CUSTOMERNAME" />
</h3>
- <xsl:for-each select="CUSTHTLVOUCHER/TEXT">
- <table>
- <tr>
- <td style="FONT-SIZE: 10pt;">
- <p>
<xsl:value-of select="@LINE" />
</p>
</td>
</tr>
</table>
</xsl:for-each>
<br />
- <xsl:for-each select="CUSTHTLVOUCHER/HOTEL">
- <div style="BACKGROUND-COLOR: blue; WIDTH: 100%;">
- <table width="100%" style="BACKGROUND-COLOR: blue;">
- <tr>
- <td align="left" style="COLOR: white; FONT-WEIGHT: bold; FONT-SIZE: 10pt;">
<xsl:value-of select="LBL1" />
</td>
- <td align="right" style="COLOR: white; FONT-WEIGHT: bold; FONT-SIZE: 10pt;">
Booking Id :
<xsl:value-of select="BOOKINGID" />
</td>
</tr>
</table>
</div>
<br />
- <DIV align="center">
- <TABLE id="tblMain" style="Z-INDEX: 106; LEFT: 72px; POSITION: static; TOP: 352px" cellSpacing="0" cellPadding="0" width="80%" align="center" border="1" bordercolor="#0099ff">
- <TR>
- <TD style="FONT-SIZE: 12pt; FONT-WEIGHT: bold; COLOR: white; BACKGROUND-COLOR: #0099ff" colSpan="3" height="15">
- <DIV id="lblHotelName">
<xsl:value-of select="NAME" />
</DIV>
</TD>
</TR>
- <TR>
- <td colspan="3">
- <table width="100%" border="0">
<tr height="15" />
- <tr>
<td align="right">Check-In:</td>
- <td>
- <div id="lblCheckIn" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black">
<xsl:value-of select="CHECKINDATE" />
</div>
</td>
<td align="right">Check-Out:</td>
- <td>
- <div id="lblCheckOut" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black">
<xsl:value-of select="CHECKOUTDATE" />
</div>
</td>
<td align="right">Rooms:</td>
- <td>
- <div id="lblRooms" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black">
<xsl:value-of select="ROOMS" />
</div>
</td>
<td align="right">Guests:</td>
- <td>
- <div id="lblGuests" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black">
<xsl:value-of select="GUESTS" />
</div>
</td>
</tr>
- <tr>
<td />
- <td>
- <div id="lblCheckInTime" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black">
<xsl:value-of select="CHECKINTIME" />
</div>
</td>
<td />
- <td>
- <div id="lblCheckOutTime" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black">
<xsl:value-of select="CHECKOUTTIME" />
</div>
</td>
<td />
<td />
<td />
<td />
</tr>
- <tr>
<td />
<td />
<td />
<td />
- <td colspan="4">
<div id="lblRoomDetail" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black">Room 1:1 Adult, 0 Child</div>
</td>
</tr>
- <tr>
<td />
</tr>
</table>
</td>
</TR>
- <TR>
<td align="center" style="FONT-WEIGHT: bold">Room Options</td>
<td align="center" style="FONT-WEIGHT: bold">Inclusions</td>
<td align="center" style="FONT-WEIGHT: bold">Guest Name</td>
</TR>
- <TR>
- <td>
- <div id="lblRoomOptions" style="FONT-SIZE: 10pt;">
<xsl:value-of select="ROOMS" />
<xsl:value-of select="ROOMSOPS" />
</div>
</td>
- <td>
- <div id="lblInclusions" style="FONT-SIZE: 10pt;">
<xsl:value-of select="INCLUSIONS" />
</div>
</td>
- <td>
- <div id="lblHotelAddress" style="FONT-SIZE: 10pt;">
<xsl:value-of select="CLIENTNAME" />
<br />
</div>
</td>
</TR>
</TABLE>
</DIV>
<br />
</xsl:for-each>
- <!-- End of Hotel Tag Loop
-->
<br />
<br />
<br />
- <xsl:for-each select="CUSTHTLVOUCHER/FOOTERTEXT">
- <table>
- <tr>
- <td style="FONT-SIZE: 10pt;">
- <p>
<xsl:value-of select="@LINE" />
</p>
</td>
</tr>
</table>
</xsl:for-each>
- <!-- End of XSL
-->
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML :
<?xml-stylesheet type="text/xsl" href="my.xsl"?>
<CUSTHTLVOUCHER><CUSTOMERNAME>Casa De </CUSTOMERNAME><TEXT LINE="some text."/><HOTEL><CLIENTNAME>MAX</CLIENTNAME><BOOKINGID>4398537</BOOKINGID><LBL1>1 Room(s) for 2 Night</LBL1><CHECKINDATE>04/18/08</CHECKINDATE><CHECKINTIME>12 pm</CHECKINTIME><CHECKOUTDATE>04/20/08</CHECKOUTDATE><CHECKOUTTIME>12 pm</CHECKOUTTIME><ROOMS>1</ROOMS><GUESTS>2</GUESTS><ROOMSOPS>Single</ROOMSOPS><INCLUSIONS>Breakfast#Two bottles of mineral water complimentary in room#Usage of Swiming Pool#</INCLUSIONS></HOTEL><TEXT LINE="The amount payable by MakeMyTrip for this booking is Rs. 8,930 including all taxes. Please email us at hotelpartner@makemytrip.com if there is any discrepancy in this payment amount."/><TEXT LINE="Line Text"/><FOOTERTEXT LINE="Sincerely,"/><FOOTERTEXT LINE="UR"/></CUSTHTLVOUCHER>
AND MY CODE IS
CREATE(xml);
CREATE(xsl);
CREATE(xmlOut);
xml.load('XML1.xml');
xsl.load('XSL1.xsl');
IF xsl.parseError.errorCode <> 0 THEN
MESSAGE('%1',xsl.parseError.reason);
xml.transformNodeToObject(xsl,xmlOut);
xmlOut.save('C:\Documents and Settings\Brij\Desktop\New Folder\mail.xml');
My requirement is to conver the XML using XSL to HTML so that
I can send that xml as mail
|
|
|
|
|
brijbmishra wrote: Yes, Actually I am working in Microsoft Dynamics NAV.
Ah. You have taken a wrong turn in some router. This is a CodeProject.com forum not the Microsoft Dynamics NAV[^] forums which are located here.[^]
And for the record, you now have two posts and ZERO questions.
Good luck.
led mike
|
|
|
|
|
led mike wrote: you now have two posts and ZERO questions.
|
|
|
|
|
I need java code that convert xsd into xml file
|
|
|
|
|
Hi!
Perhaps someone can give me a push in the right direction?
I've got an XML file I want to validate using an XMLSchema. One of the elements has an attribute that can be optional if another attribute has a certain value and that is required in other cases.
Is there a way to include such conditions into an XSD or do I have to validate this condition manually?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Interesting question.
You are asking about something called a co-occurrence constraint. XML Schema does not directly support co-occurrence constraints, but it is an area some people are researching.
A researcher, Fabio Vitali, has done some work in this area and has come up with a solution that pre-processes a special file that results in a new XML schema. The new XML schema is then used to validate instance documents.
Here's the link http://tesi.fabio.web.cs.unibo.it/Tesi/SchemaPath[^] - click the link "SchemaPathImplementations" for the stylesheets and other files you'll need.
A much simpler approach is to validate this manually, but Fabio Vitali offers a way using XSL and XML Schema - which is pretty cool!
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
Great, thanks for the reply!
I'll take a look at the link.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
How do I generate a < symbol using <xsl:text>?
I have the following:
<xsl:text disable-output-escaping="yes">
a < b
</xsl:text>
but this would generate an error, (unexpected token)
If I use:
<xsl:text disable-output-escaping="yes">
a < b
</xsl:text>
the text that is generated is
a < b
what would I need to do to have
a < b
to be generated?
thanks
|
|
|
|
|
Hi!
Hmmm... the last code example you provided works fine for me.
But if you're sure you're doing everything else right, try changing your output type to HTML:
<xsl:output method="html"/>
Add this just below your xsl:stylesheet tag if you don't already have an output type, change it to "html" if you do.
It could work but I can't replicate your problem so I have no way to be sure.
Hope This Helps!
MrWolfy
|
|
|
|
|
You can always use a CDATA section if the & escape is causing problems.
|
|
|
|
|
Just use entity references: < > and &
It might be messy to go through an entire XML doc to convert values containing these special characters so, in the past, I used to just load the XML into a XML DOM object and then get it again - the DOM object does the conversion for you!
(ignore the HTML tags in my sig - I turned off HTML so that the entity references show up)
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
Hi,
While calling the validate method I am getting the following error while validating the XML:
<b>"Validate failed because the document does not contain exactly one root node."</b>
The XMLDOM object i am creating is Msxml2.DOMDocument.4.0
I am having only one root but don't know why this error
Here is my XSD:
<xsd:schema id="XSDSchemaTest" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="DriverDetails">
<xsd:sequence>
<xsd:element name="VendorURLPath" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="DriverCureServerURLPath" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="MD5" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ProductName" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="DriverVersionInfo" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ContentWriterInfo" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Drivers">
<xsd:complexType>
<xsd:choice>
<xsd:element name="Driver" type="DriverDetails" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
And here is the XML :
<?xml version="1.0" encoding="UTF-8" ?>
<Drivers xsd:SchemaLocation="F:\kuldeep\ProjectWork\XMLExtractorMFC\XMLSchema.xsd">
<Driver>
<VendorURLPath123>http://www.yahoo.com</VendorURLPath123>
<DriverCureServerURLPath>http://www.yahoo.com</DriverCureServerURLPath>
<MD5>12345678</MD5>
<ProductName123>abcd</ProductName123>
<DriverVersionInfo>Version No 1.1</DriverVersionInfo>
<ContentWriterInfo>Made By Microsoft</ContentWriterInfo>
</Driver>
</Drivers>
Anyone Please let me know what can be problem with this.
Kuldeep
|
|
|
|
|
The schema location attribute in the root node is wrong, since you don't have a namespace in your instance. Here is an instance that works:
<Drivers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="F:\kuldeep\ProjectWork\XMLExtractorMFC\XMLSchema.xsd">
<Driver>
<VendorURLPath/>
<DriverCureServerURLPath/>
<MD5/>
<ProductName/>
<DriverVersionInfo/>
<ContentWriterInfo/>
</Driver>
</Drivers>
Also make sure that your schema actually exists at the specified location and is valid.
Here's some more information:
http://msdn.microsoft.com/en-us/library/ms256139(VS.85).aspx
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|