How to get the name and value of an attribute on a node/element that is not a child
Hello,
Can someone shed some wisdom on how I can compare 2 xml nodes for differences.
My main challenge is I need to use the attributes/values of 'ProductDescription' and 'Features' as 'key' to identify the same node in
another doc with the same layout, but different content.
I am having trouble getting the name of the attribute on the node, 'ProductDescription' and 'Features'. I can only seem to get the node names, but not the attributes on the node. I need the name, because it can be different from doc to doc, so
I can't hardcode this.
Can someone please help with how to retrieve an attribute name/value on a node that is not a child. Here's an example of what
my xml looks like:
DECLARE
@myDoc1 xml
,@mydoc2 xml
DECLARE
@ProdID int
SET @myDoc1 ='<ProductDescription ProductID="1" ProductName="Road Bike">
<Features featureID = "1" featureName = "body">
<Warranty>1 year parts and labor</Warranty>
<Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
</Features>
<features featureID = "2" featureName = "seat">
<Warranty>1 year parts and labor</Warranty>
<Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
</Features>
</ProductDescription>
SET @myDoc2 ='<ProductDescription ProductID="1" ProductName="Road Bike">
<Features featureID = "1" featureName = "body">
<Warranty>2 year parts and labor</Warranty>
<Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
</Features>
<features featureID = "2" featureName = "wheel">
<Warranty>1 year parts and labor</Warranty>
<Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
</Features>
</ProductDescription>
I need to compare the attributes of 'ProductDescription' and 'Features' from @mydoc1 against @mydoc2 to see if they are the same based on those 2 nodes first. If they are, then i want to show the difference in the child elements.
This will eventually be an outer join to give me the differences betw the 2 docs based on those key values (node attributes).
I used node('//*') for the path, and value('local-name(../.)', 'varchar(50)') as element
,value('.[not(@xsi:nil = "true")]','VARCHAR(255)') AS new_value
...etc...
but that only gives me the node names, and the child elements. It does not give me back the attribute names and values from the node itself.
Thanks in advance for your help.
cee
Are you looking for something like this:
DECLARE @myDoc1 xml
SET @myDoc1 ='<ProductDescription ProductID="1" ProductName="Road Bike">
<Features featureID = "1" featureName = "body">
<Warranty>1 year parts and labor</Warranty>
<Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
</Features>
<Features featureID = "2" featureName = "seat">
<Warranty>1 year parts and labor</Warranty>
<Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
</Features>
</ProductDescription>'
SELECT T.c.value('local-name(.)', 'nvarchar(50)') AS name,
T.c.value('.', 'nvarchar(50)') AS value
FROM @myDoc1.nodes('ProductDescription/@*') AS T(c)
Erland Sommarskog, SQL Server MVP, [email protected]
Similar Messages
-
How to get Cookie Name and Value Using HttpGetterCallback - CE 7.3
Hi All,
We are migrating from Netweaver 7.0 to 7.3. We are facing a issue when migrating the custom login module from 7.0 to 7.3.
Since WebCallback is deprecated and not to be used in Netweaver 7.3, we are finding difficulties in getting the cookie name and value. Please find below our coding for getting the cookie value using HttpGetterCallback. We are not getting the cookie name and value, Kindly let us know if we are implementing the HttpGetterCallback correctly.
HttpGetterCallback httpGetCookieCallback = new HttpGetterCallback();
httpGetCookieCallback.setType(HttpCallback.COOKIE);
Callback] callbks = new Callback[ { httpGetUrlCallback, httpGetCookieCallback };
callbackHandler.handle(callbks);
requestUrl = (String) httpGetUrlCallback.getValue();
Cookie] cookies = (Cookie [) httpGetCookieCallback.getValue();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
location.debugT("Cookies name " + cookies.getName()
+ " - value "
+ cookies.getValue());
Thanks and Regards,
SaravananTry This-
Cookie cookiesArray[] = request.getCookies();
Cookie currentCookie = null;
String currentCookieName = "";
String cookieValue = "dummycookie";
int cookieArrayLength = cookiesArray.length;
for (int i = 0; i < cookieArrayLength; i++) {
currentCookie = cookiesArray<i>;
currentCookieName = currentCookie.getName();
cookieValue = currentCookie.getValue();
Regards,
Atul -
How to get the name and the path of the font used in photoshop (not textItem.font)
I'm trying to get the real name of the font and the path, is there a "easy" way to do it ?
i need to get the font file (*.ttf or *.otf) and copy to the same directory as the psd file, that's why textItem.font doen't work for me.
thanks in advanceYou could try this as it looks as if you are using Windows.
Run the VBS script to create a fontlist file on the desktop.
Then run the javaScript on the PSD document.
It should copy the fonts to the same folder as the document, it will also create a text file with a list of fonts.
It didn't find all the fonts in my test psd maybe because it wasn't in the windows/font folder?
VBS.
Set wshShell = WScript.CreateObject("WScript.Shell")
Set wshSysEnv = wshShell.Environment("PROCESS")
sMyFile = "c:" & wshSysEnv("HOMEPATH") & "\Desktop\Fontlist.txt"
Dim objFileSystem, objOutputFile
Dim strOutputFile
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(sMyFile, TRUE)
Dim str
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Fonts"
objReg.EnumValues HKEY_LOCAL_MACHINE, _
strKeyPath,arrEntryNames,arrEntryZZZ
For Each entry in arrEntryNames
str = wshshell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\" & entry)
objOutputFile.WriteLine(entry & "," & str)
Next
objOutputFile.Close
javaScript.
#target photoshop;
app.bringToFront();
main();
function main(){
if(!documents.length) return;
try{
var Path = activeDocument.path;
}catch(e){
alert("This document needs to be saved before running this script!");
return;
var FontFile = File(Folder.desktop + "/FontList.txt");
if(!FontFile.exists){
alert("You need to run the vbs script first to create the FontList file!");
return;
var FontList = new Array();
FontFile.open('r') ;
while(!FontFile.eof){
strInputLine =FontFile.readln();
if (strInputLine.length > 3) inputArray = strInputLine.split(",");
if(inputArray.length == 2) FontList.push([[inputArray[0]],[inputArray[1]]]);
FontFile.close();
var PSDtextLayers = getNamesPlusIDs();
PSDtextLayers = UniqueSortedList(PSDtextLayers);
for(var a in PSDtextLayers){
for(var f in FontList){
var rex = new RegExp;
rex = PSDtextLayers[a].toString();
if(FontList[f][1].toString().match(rex,"i")){
var From = new File("/c/windows/fonts/" + FontList[f][1].toString());
var To = new File(Path + "/"+ FontList[f][1].toString());
From.copy(To);
break;
var rFonts = new File(Path + "/required Fonts.txt");
rFonts.open('w');
rFonts.write(PSDtextLayers.join('\n'));
rFonts.close();
function UniqueSortedList(ArrayName){
var unduped = new Object;
for (var i = 0; i < ArrayName.length; i++) {
unduped[ArrayName[i]] = ArrayName[i];
var uniques = new Array;for (var k in unduped) {
uniques.push(unduped[k]);}
return uniques;
function getNamesPlusIDs(){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( 'NmbL' ));
ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
var Names=[];
try{
activeDocument.backgroundLayer;
var i = 0; }catch(e){ var i = 1; };
for(i;i<count;i++){
if(i == 0) continue;
ref = new ActionReference();
ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
var desc = executeActionGet(ref);
var layerName = desc.getString(charIDToTypeID( 'Nm ' ));
var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
if(layerName.match(/^<\/Layer group/) ) continue;
if (desc.hasKey(stringIDToTypeID('textKey'))){
desc = desc.getObjectValue(stringIDToTypeID('textKey'));
desc = desc.getList(stringIDToTypeID('textStyleRange')).getObjectValue(0).getObjectValue(stringIDToTypeID('textStyle'));
var postScriptName = desc.getString( stringIDToTypeID('fontPostScriptName'));
Names.push(postScriptName);
return Names; -
How to get the name of a duplicated control or created control and add a callback to it
Hi All,
Depending on how many input points I need, I am duplicating a numeric or string input with the DuplicateCtrl function. My question is, how do I get the name and id of the control that was just created, and how can i assign a callback to it? Alternately, would it be better to create a fresh ctrl instead of duplicating?
Thanks in advance!
Solved!
Go to Solution.Hi TurboMetrologist,
why are you trying to get the control constant name? Keep in mind that you cannot use that name to address the control; control names are actually simply macros in the include file associated to the UIR, that is, the compiler preprocesses the code and wherever it finds PANEL_CONTROL names substitutes the corresponding numeric value as parameters to the functions (and consequently 'control' parameter is an int and not a char*)
That is why NewCtrl () or DuplicateCtrl () functions return a control ID: it is the handle to the new object, our only way to manipulate it. You will need to store this handle into a non-volatile memory so that you can access it durng program life.
Additionally, there are other ways to assign some particular meaning to a control than swiching on the control constant name. You could for example use the callbackData parameter to differentiate between different copies of a control.
Let me explain with an example. You told that you need several inputs (dynamically created as you don't know in advance how many of them to use); a clean solution could be to:
Design a master copy of one control in the UIR editor, where it is easy to customize it; assign also a callback function, if it has to be common to all copies of the control
Programmatically assign a callbackData value to that control, e.g. SetCtrlAttribute (..., ..., ATTR_CALLBACK_DATA, (void *)1);
Duplicate the control and then assign a different callbackData
for (i = 2; i < 5; i++) {
handle = DuplicateCtrl (...);
SetCtrlAttribute (..., handle, ATTR_CALLBACK_DATA, (void *)i);
By operating this way, every time the control callback is fired by any control it will receive the assigned callbackData, and you will be able to differentiate your code by a simple switch:
switch ((int)callbackData) {
case 1: // The master control
break;
case 2: // The first duplicated control
break;
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
How to get the name of the current tab.
Hi Experts,
I have two tabs in my tab strip and a button common to both the tabs.Can you please let me know how to get the name of the current tab in the event method of the push button.
Thanks in advance.
Regards,
Arun1.Declare an Action for OnSelect event of Tabstrip. This event is triggered whenever any change in tab occurs.
2. Declare an Import Parameter in this method
Tab type String.
3. This parameter has value of the selected TAB.
4. You can set this value in some Attribute in Attribute Tab in this event only (OnSelect):
wd_this->Att = Tab.
Att is the attribute created by you in Attributes Tab of View. ( of type String)
5. Now the selected Tab ID is stored in this Attribute Att.
6. In the Onaction of Button , retrieve the selected tab value from this attribute using :
Data : lv type string.
lv = wd_this->Att
Now lv has your selected TAB ID.
I hope it would help you.
Edited by: Saurav Mago on Oct 13, 2009 2:22 PM -
How to get the current month value for a customer exit variable?
How to get the current month value for a customer exit variable?
And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
Thanks!Hi Kevin,
Check here........
Re: Customer Exist for "From Current Date To Month End"
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
Cal month
Regards,
Vijay. -
How to get the previoulsy selected value in a combobox
How to get the previoulsy selected value in a combobox. i WANT the current and the previously selected value of the combobox.
Just add to combobox ItemListener. When item is changing in itemStateChanged arrives 2 events. ItemEvent.DESELECTED and ItemEvent.SELECTED with corresponding item's values. Just write something like this:
comboBox.addItemListener(new ItemListener() {
Object prevValue;
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
//do what you need with prevValue here
} else {
prevValue = e.getItem();
}); -
How to get the name of a Data Element of a generic Table!
Hi guys!
In my function i have the following import paramenter
i_outtab type standard table
now i import a table and i want to get the dataelement of the fields.
is there a way to do this??Hello Thomas
Perhaps the following sample report may be useful for you.
*& Report ZUS_SDN_RTTI_STRUCT_COMPONENTS
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1145711"></a>
*& Thread: How to get the name of a Data Element of a generic Table!
REPORT zus_sdn_rtti_struct_components.
TYPE-POOLS: abap.
TYPES: BEGIN OF ty_s_outtab.
TYPES: bukrs TYPE bukrs.
TYPES: kunnr TYPE kunnr.
TYPES: END OF ty_s_outtab.
DATA: gdo_data TYPE REF TO data.
DATA: gs_outtab TYPE ty_s_outtab.
DATA: go_typedescr TYPE REF TO cl_abap_typedescr,
go_structdescr TYPE REF TO cl_abap_structdescr,
go_datadescr type ref to cl_abap_datadescr.
DATA: gs_comp TYPE abap_compdescr,
gd_dtel type string,
gt_dfies type ddfields.
FIELD-SYMBOLS:
<gs_struct> TYPE ANY.
START-OF-SELECTION.
BREAK-POINT.
GET REFERENCE OF gs_outtab INTO gdo_data.
ASSIGN gdo_data->* TO <gs_struct>.
go_typedescr = cl_abap_typedescr=>describe_by_data( <gs_struct> ).
go_structdescr ?= go_typedescr.
BREAK-POINT.
LOOP AT go_structdescr->components INTO gs_comp.
go_datadescr = GO_STRUCTDESCR->GET_COMPONENT_TYPE( gs_comp-name ).
gd_dtel = go_datadescr->get_relative_name( ).
write: / syst-tabix, 'Data element =', gd_dtel.
ENDLOOP.
END-OF-SELECTION.
Regards
Uwe -
How to get the anchor tag values in next jsp
Hey all,
I have two jsp files.
in first jsp,
I am getting the resultset.
I am setting the resultset to the anchor tag.
below is the code...
<a target="_top" rel="contents" rev="contents" class="fordynamiclabel" href="ASCMasterTwo.jsp"><%=rSet.getString(1) %></a></td>
whenever he click on any anchor tag,
It will goes to ACSMasterTwo.jsp page for edit the compleate record.
how to get the anchor tag value in that page...
Please help me on this.You have to pass a parameter. An id is good.
Of course you have to get an id from somewhere in the result set right?
<a target="_top" rel="contents" rev="contents" class="fordynamiclabel" href="ASCMasterTwo.jsp?id=<%= rSet.getString("id") %>"><%=rSet.getString(1) %></a></td>Then you call
request.getParameter("id");
and look up the values related to that id in the database. -
How to change the name and description of a wim using DISM
With Imagex we could update the name and description of the wim with on easy command:
imagex /info img_file [img_number or
img_name] [new_name] [new_desc]
e.g.
imagex /info Win7Combined.WIM 1 "Win7(x86)" "Windows 7 x86"
Since the ImageX tool is deprecated in Windows 8 and has been replaced with DISM, can someone explain how to update the name and description with one easy command using DISM like we could with Imagex?It looks like this person had the same issue. Have you seen this
link
It talks about exporting an Index into a new WIM. Which, in a way, would be renaming it. It's really recreating it and you have to give it a name. But it seems to work.
Dustin Estes - MCP | www.dustinestes.com -
How to get the Title and Tcode of a Program during run time
Hello,
I am new to abap and I have this question please. Is the a way to get the title, Tcode and Author of a program during run time? I would like to get the name and title of a program or a view or an include during run time.
Using table TADIR, you can only get the object_name and the author. Is the a way for me to get the Title of the repository object and any Tcode if any is available for the case of a program?
I loop forward for your respond.
Thank you.
SabinaYou can get it by accessing SYST.
SY-TITLE for Title
SY-TCODE for Tcode
I don't think there is any field in SYST for the Author.
To get the author name you can use the TRDIR table.
Regards,
Naimesh Patel -
How to get the latest procured value of a spare updated in material master
How to get the latest procured value of a spare updated in material master
J S S PRASAD
See table MBEW via transaction SE16.
However, you may need to look at the last PO created for that material.
PeteA -
How to get the previous record value in the current record plz help me...
In my sql how to get the previous record value...
in table i m having the field called Date i want find the difference b/w 2nd record date value with first record date... plz any one help me to know this i m waiting for ur reply....
Thanx in Advance
with regards
kotreshFirst of this not hte mysql or database forum so don;t repeate again.
to get diff between two date in mysql use date_format() to convert them to date if they r not date type
then use - (minus)to get diff. -
I have an Apple I Phone 4S which is great but, can someone help me how to get the photos and videos to my PC which runs on MS XP. I would like to be able to edit and copy photos and videos to a DVD.
Connect your iPhone to your computer. Tp your pc should recognize your iPhone as a camera. Use what ever application you have on the pc to transfer files from a camera to your computer.
-
I get the following message when I open Photoshop: Photoshop detected graphics hardware that is not officially supported...which asks me to "uncheck the use Graphics Processor...but there is no Graphics Processor to check ?????? What do I need to do? I have ignored this in the past and Photoshop seems to work OK but still I wonder why this opens every time I start Photoshop. Thanks for considering my question.:>)
As you can see use Graphics Processor is NOT checked. Now what? And a special thanks for answering me about this. :>)
Diana
Maybe you are looking for
-
I'd like to receive some clarification on an issue I certainly feel deserves it. Please keep in mind any reference to "original media" need not be digital at all or in any way under the control of Adobe before being loaded or converted to PDF format.
-
Set isolation level in EJB 2.0
how can i set isolation level to a transaction in EJB 2.0. If anybody can give example code much appriciated
-
I've a procedure to load a file into a table: CREATE OR REPLACE PROCEDURE load_xml (p_dir IN VARCHAR2, p_filename IN VARCHAR2) AS l_bfile BFILE := BFILENAME(p_dir, p_filename); l_clob CLOB; BEGIN DBMS_LOB.createtemporary (l_clob, TRUE); DBMS_LOB.file
-
Iam from Vijayawada. I want to present a Ipad to my sister in UK. Is it possible.
-
Device: iPod Touch 4G It tells me that and doesnt work for nothing, it's been like this for 5 days already. I cant download from the AppStore from my iPod Touch 4G either.