Append an XML Fragment using powershell
I m running into an issues appending an xml attribute fragment. I had this working but now im getting the below errors. Below is the default xml structure and I want to add items under the Assignments node.
<?xml version="1.0"?>
<Database>
<Info>
<Name>FinalTest</Name>
<TotalComputers>759</TotalComputers>
<Assigned>0</Assigned>
<Unassigned>759</Unassigned>
</Info>
<Assignments/>
</Database>
My Code:
[XML]$xml = Get-Content "C:\Users\shuppz\Desktop\FinalTest.xml"
$txt = @"
<Assignment>
<File>First_Last.xlsx</File>
<Computers>Computer1, Computer2, Computer3</Computers>
<Assigned>12/12/1212</Assigned>
<Due>12/21/1212</Due>
</Assignment>
$xmlFragment=$xml.CreateDocumentFragment($txt)
$node=$xml.SelectSingleNode('//Assignments')
$node.AppendChild($xmlFragment)
The Errors:
Cannot find an overload for "CreateDocumentFragment" and the argument count: "1".
At line:12 char:1
+ $xmlFragment=$xml.CreateDocumentFragment($txt)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
Exception calling "AppendChild" with "1" argument(s): "Object reference not set to an instance of
an object."
At line:14 char:1
+ $node.AppendChild($xmlFragment)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
If I do $XML | GM I see that CreateDocumentFragment, if someone could show me what im doing wrong. Im sure im missing something simple.
Okay. I test that out and it work but the formatting is thrown off a little. do you know if there would be a way to fix that?
<?xml version="1.0"?>
<Database>
<Info>
<Name>FinalTest</Name>
<TotalComputers>759</TotalComputers>
<Assigned>0</Assigned>
<Unassigned>759</Unassigned>
</Info>
<Assignments> <Assignment>
<File>First_Last.xlsx</File>
<Computers>Computer1, Computer2, Computer3</Computers>
<Assigned>12/12/1212</Assigned>
<Due>12/21/1212</Due>
</Assignment></Assignments>
</Database>
Similar Messages
-
Assign default namespace to XML fragment using XQuery
Hi everybody!
I need to add a default namespace declaration to a XML fragment using XQuery. I wrote following statement to assign fragment to $body:
<soap-env:Body>{
fn-bea:inlinedXML($content/text())}
</soap-env:Body>
The problem is "$content/text()" has no namespace declaration so I need to assign a default namespace (xmlns="") to it in order to apply some XQuery transformations to its content.
I know this can be easily done with a XSLT but I would like use XQuery instead.
Could anyone tell me how I could perform this task?
Thank you in advance,
Daniel.Re: xquery function - send namespace as binding variable and define it in a tag
-
How To Store XML Fragments Using Functions Such As XMLElement
Hi
Not sure what I am missing. I wish to store XML fragments in variables so can pass around and concatenate with other fragments to make final XML document. Even before attempting to concatenate XML fragments, I am struggling to store any XML fragment in a variable. I am trying to use simple functions such as XMLElement to generate XML so can store in variable. I have seen many examples of XMLElement in SQL select statement. Can XMLElement be used in plsql? XMLElement says it returns value of type XMLType. Functions such as XMLElement make generating XML easier than creating all tags manually.
Below is simple example that demonstrates what I would like to do. I would like to be able to pass the XML fragment as either XMLType or clob. I receive error saying PLS-00201: identifier 'XMLELEMENT' must be declared
declare
vTheData XMLType;
vTheDataClob clob;
begin
vTheData:= XMLelement("empno",'1234567');
vTheDataClob:= xmlelement("empno",'1234567').getclobval();
end;
Where as I can use below, but surely don't have to use select into from dual method. I just expect can use XMLElement function in plsql same as sql, such as most other functions eg length, rtrim etc.
declare
vTheData XMLType;
vTheDataClob clob;
begin
select xmlelement("empno",'1234567')
into vTheData
from dual;
select xmlelement("empno",'1234567').getclobval()
into vTheDataClob
from dual;
end;
Hope this makes sense.
ThanksHaving said that, is there a more elegant way to achieve below. That is populate two XML fragments and concatenate together.
Sure, why not just only one statement?
select XMLConcat(
XMLElement( ... )
, XMLElement( ... )
into vTheResult
from dual;
As a second question, is it better to build and pass XML fragments as XMLType or clob?
I would say stay with XMLType but it depends on your requirement.
I generally avoid passing around pieces of data, SQL/XML functions are powerful in the way they can be used with set operations, so using them in a piecewise approach kinda negates what they're for. -
Using value of a variable in XML fragment
Hi,
I am assigning an xml fragment to a webservice variable. The XML fragment is as mentioned below:
<ns2:ArrayOfKeyValuePair xmlns:ns2="http://www.themindelectric.com/package/com.taw.cca.common/"
xsi:type="soapenc:Array"
soapenc:arrayType="ns2:KeyValuePair[1]"
xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<item xsi:type="ns2:KeyValuePair">
<key xsi:type="xsd:string">key</key>
*<value xsi:type="xsd:string" > 1234</value>*
</item>
</ns2:ArrayOfKeyValuePair>
In the above mentioned xml fragment, for the tag value I need to pass the data of a variable instead of the hardcoded string 1234. How can I resolve my issue?
ThanksIn the worst case, you could always resort to using scriptlets to retrieve the parameter. and set it up as an attribute in the local page scope.
<%
String param = (String)request.getParameter("collection");
Collection userCollection = (Collection)request.getAttribute(param);
pageContext.setAttribute("local_collection", userCollection);
%>
<forEach var="user" items="${local_collection}">
,,,I think this should work.
JSTL is great, but it can't yet replace every scriptlet, much as I would like it to. -
Download RSS feed as xml file from Sharepoint Online using PowerShell
Hello
Our company sharepoint (Office 365) contains also several RSS feeds.
How it is possible to download xml file out of this feed (website) using PowerShell?
I can authenticate with sharepoint using CSOM but do not what to do next.
As service user is not administrator I cannot use "SPOService".
This script works OK for standard website, but not for Sharepoint.
$doc = New-Object System.Xml.XmlDocument
$doc.Load("http://www.{CompanySite}.com/feed/")
$doc.save("C:\temp\feed.xml")
I am getting this error when using for company Sharepoint:
"The remote server returned an error: (403) Forbidden."
Thanks for your time considering this question.
JozinHi Scott,
thanks for advice.
Combination of WebClient and Sharepoint Credentials is working OK:
$client = New-Object System.Net.WebClient
$client.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User, $SecurePassword)
$client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
$client.DownloadFile($SiteURL, $file) -
How to use XML fragment in BPEL?
Hello,
How to use XML fragment in BPEL process and whats the purpose of XML fragment ? And why we need it ??It is used to build up an XML fragment to the element on the target side...
please refer this link....
http://kr.forums.oracle.com/forums/thread.jspa?threadID=2252997&tstart=2
Thanks,
N -
Using XMLAgg with non-wellformed XML fragments
Hi,
with XMLAgg one can create a non-wellformed XML-Fragement ( i.e. with multiple root elements ) like
<foo>bar1</foo>
<foo>bar2</foo>
where each foo element comes from a table row ( e.g. from a single-column table with the rows 'bar1' and 'bar2' ).
However, I wasn't able to get a similar result when creating multiple elements per row. I defined a function that returns a non-wellformed fragment like
<foo>bar1</foo>
<oof>bar1</oof>
per row, but I couldn't aggregate these fragments using XMLAgg. The result should look like ( 2 elements per row )
<foo>bar1</foo>
<oof>bar1</oof>
<foo>bar2</foo>
<oof>bar2</oof>
Instead, i got an "LPX-00245: extra data after end of document" error ( whole error see below ).
I wonder why it is possible to create non-wellformed fragments with XMLAgg, but why there seems to be impossible to aggregate them.
Regards,
Pat
The whole error message ( sorry, the DBMS is configured for german language ):
ORA-29400: Data Cartridge-Fehler
ORA-31011: XML-Parsing nicht erfolgreich
ORA-19202: Fehler bei XML-Verarbeitung
LPX-00245: extra data after end of document
Error at line 1
aufgetreten
ORA-06512: in "TEST.DOC", Zeile 31
29400. 00000 - "data cartridge error\n%s"
*Cause: An error has occurred in a data cartridge external procedure.
This message will be followed by a second message giving
more details about the data cartridge error.
*Action: See the data cartridge documentation
for an explanation of the second error message.Even in 9i I can aggregate without root element:
SQL> set timing off
SQL> select * from v$version where rownum = 1
BANNER
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
1 row selected.
SQL> with t as (
select 1 id, xmltype( '<foo>bar1</foo>') xml from dual union all
select 1, xmltype( '<foo>bar1</foo>') from dual union all
select 2, xmltype( '<foo>bar1</foo>') from dual union all
select 2, xmltype( '<foo>bar1</foo>') from dual
select xmlagg(xml) xml from (
select id, xmlagg(xml) xml from t group by id)
XML
<foo>bar1</foo>
<foo>bar1</foo>
<foo>bar1</foo>
<foo>bar1</foo>
1 row selected. -
Getting ORA-22805 when trying to load XML file using SQLLDR
I'm trying to learn the basics of XML since we'll be getting XML files in the near future. I'm using one of the sample schemas that comes with XMLSPY. I loaded this schema into an 11g Oracle DB using XMLSPY:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.0 NT beta 1 build Jun 13 2001 (http://www.xmlspy.com) by Alexander Falk (Altova, Inc.) -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ipo="http://www.altova.com/IPO" targetNamespace="http://www.altova.com/IPO" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<annotation>
<documentation>
International Purchase order schema for Example.com
Copyright 2000 Example.com. All rights reserved.
</documentation>
</annotation>
<!-- include address constructs -->
<include schemaLocation="address.xsd"/>
<element name="purchaseOrder" type="ipo:PurchaseOrderType"/>
<element name="comment" type="string"/>
<complexType name="PurchaseOrderType">
<sequence>
<element name="shipTo" type="ipo:Address"/>
<element name="billTo" type="ipo:Address"/>
<element ref="ipo:comment" minOccurs="0"/>
<element name="Items" type="ipo:Items"/>
</sequence>
<attribute name="orderDate" type="date"/>
</complexType>
<complexType name="Items">
<sequence>
<element name="item" minOccurs="0" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="productName" type="string"/>
<element name="quantity">
<simpleType>
<restriction base="positiveInteger">
<maxExclusive value="100"/>
</restriction>
</simpleType>
</element>
<element name="price" type="decimal"/>
<element ref="ipo:comment" minOccurs="0"/>
<element name="shipDate" type="date" minOccurs="0"/>
</sequence>
<attribute name="partNum" type="ipo:Sku"/>
</complexType>
</element>
</sequence>
</complexType>
<simpleType name="Sku">
<restriction base="string">
<pattern value="\d{3}-[A-Z]{2}"/>
</restriction>
</simpleType>
</schema>
Then I created an XMLType table:
CREATE TABLE purchaseOrder OF XMLType
XMLSCHEMA "ipo.xsd" ELEMENT "purchaseOrder"
I'm trying to load the sample XML file ipo.xml into purchaseOrder using SQLLDR. This is ipo.xml:
<?xml version="1.0"?>
<!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Mr. Nobody (Altova GmbH) -->
<ipo:purchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ipo="http://www.altova.com/IPO" orderDate="1999-12-01" xsi:schemaLocation="http://www.altova.com/IPO
ipo.xsd">
<shipTo export-code="1" xsi:type="ipo:EU-Address">
<ipo:name>Helen Zoe</ipo:name>
<ipo:street>47 Eden Street</ipo:street>
<ipo:city>Cambridge</ipo:city>
<ipo:postcode>126</ipo:postcode>
</shipTo>
<billTo xsi:type="ipo:US-Address">
<ipo:name>Robert Smith</ipo:name>
<ipo:street>8 Oak Avenue</ipo:street>
<ipo:city>Old Town</ipo:city>
<ipo:state>AK</ipo:state>
<ipo:zip>95819</ipo:zip>
</billTo>
<Items>
<item partNum="833-AA">
<productName>Lapis necklace</productName>
<quantity>2</quantity>
<price>99.95</price>
<ipo:comment>Need this for the holidays!</ipo:comment>
<shipDate>1999-12-05</shipDate>
</item>
<item partNum="748-OT">
<productName>Diamond heart</productName>
<quantity>1</quantity>
<price>248.90</price>
<ipo:comment>Valentine's day packaging.</ipo:comment>
<shipDate>2000-02-14</shipDate>
</item>
<item partNum="783-KL">
<productName>Uncut diamond</productName>
<quantity>7</quantity>
<price>79.90</price>
<shipDate>2000-01-07</shipDate>
</item>
<item partNum="238-KK">
<productName>Amber ring</productName>
<quantity>3</quantity>
<price>89.90</price>
<ipo:comment>With no inclusions, please.</ipo:comment>
<shipDate>2000-01-07</shipDate>
</item>
<item partNum="229-OB">
<productName>Pearl necklace</productName>
<quantity>1</quantity>
<price>4879.00</price>
<shipDate>1999-12-05</shipDate>
</item>
<item partNum="128-UL">
<productName>Jade earring</productName>
<quantity>5</quantity>
<price>179.90</price>
<shipDate>2000-02-14</shipDate>
</item>
</Items>
</ipo:purchaseOrder>
This is what's in the control file:
LOAD DATA
INFILE *
INTO TABLE purchaseOrder TRUNCATE
xmltype(xmldata)
FIELDS
xmldata LOBFILE (CONSTANT ipo.xml)
BEGINDATA
0
The load fails with:
Record 1: Rejected - Error on table PURCHASEORDER.
ORA-22805: cannot insert NULL object into object tables or nested tables
Another question I have is, how do we know how many records (0's) to specify in the control file? In this case there's only one but when real files are used we won't know how many are in the file.
Thanks for your help!The concept was "Don't use SQL*Loader to parse XML".
You can use SQL*Loader to load an entire XML document into the DB. That is fine. You can do the same via BFILENAME to read in files from disk as well.
If you want to parse XML, do that from within Oracle via PL/SQL and/or SQL. The solution depends upon your version of Oracle and what is good enough for you in terms of performance.
So the basics are
a) How am I getting the information?
b) How am I getting in into Oracle?
c) How do I want to parse it?
As I see the schema, it only allows for one ipo:purchaseOrder node in the document, since that is the root node. If you have multiple in the incoming file, you no longer have valid XML, both per the schema and because you have no single root node. You have an XML fragment, which must be treated different.
Just trying to understand the question since I now realize it does not agree with what the schema in your initial example shows. -
Creating a Scheduled Task using PowerShell v4
So here is my question. I'm trying/wanting to create a scheduled task using PowerShell v4 on Server 2012R2. I want to task to run on the 1st day of every month. The parameter for -Monthly -Day is not available. I need to use PowerShell
to create the Scheduled Task because the Task will be running with a group Managed Service Account credentials so the Scheduled Task can not be created via the Task Scheduler GUI.
Thanks in AdvanceHere is a functioning task It can be easily edited in PowerShell or in notepad to alter the timing
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Author>W8TEST\user01</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2014-06-04T21:31:32.0459499</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByMonth>
<DaysOfMonth>
<Day>1</Day>
<Day>12</Day>
<Day>24</Day>
</DaysOfMonth>
<Months>
<January />
<February />
<March />
<April />
<May />
<June />
<July />
<August /
<September />
<October />
<November />
<December />
</Months>
</ScheduleByMonth>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<RunLevel>LeastPrivilege</RunLevel>
<UserId>W8TEST\jvierra</UserId>
<LogonType>InteractiveToken</LogonType>
</Principal>
</Principals>
<Settings>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>notepad.exe</Command>
<Arguments>test.txt</Arguments>
<WorkingDirectory>c:\temp</WorkingDirectory>
</Exec>
</Actions>
</Task>
I have edited and reloaded the XML many, many times. It works very nicely.
¯\_(ツ)_/¯ -
How can I query a https website used to display the status of an application using Powershell?
Need assistance on querying the status of an application using Powershell. The status of the application is displayed in a https website. I want to receive a notification when one of the listed applications fails.
Below is an example the failures I need to capture.
h-t-t-p-::://xpps2.xxcom/ssol/sSOLStatus.asp?autorun
SSOL Status
Current App Server: xpps2.xx.com
SQL Server Details:
SSS_MyAccount DB Connection: PASS
SSS_MyAccount DB Query: PASS
CAGWEB DB Connection: FAIL - Unable to Connect
CAGWEB DB Query: FAIL - Pay location not found
DB2 Server Details:
DB2 D Connection: PASS
DB2 Q Query: FAIL -Acct not found
DB2 X Query: PASS
DB2 N Query: PASS
DB2 S Query: PASS
DB2 K Query: PASS
DB2 I Query: PASS
Mitem Server Details:
MITEM server: MITEMP2
MITEM Total Devices: 10
MITEM Devices Lines Up: 10
MITEM Devices Logged In: 10
MITEM Devices In Use: 0
Mitem Server Status: PASS
Web Service Details:
SAW Web Service Status: FAIL
Maximo Vizcainothats where you are going to check what it is supposed to be.
lets say your page shows as SSOL Status : running you
probably want to use "if($totalstrng.ToLower().contains("ssqlL status
: running"))". its
checking if the html page contains the string you are looking for.
you might want to print $totalstrng
and see what you need to look for.
usign XMLHttp
or XML object as mentioned by JRV might be easier and faster way. -
Hello all,
Could you possibly help me with provider-hosted app development/deployment process.
We developed SharePoint provider-hosted app that works just fine in development environment. Now we need to automate it's installation in test environment via powershell.
In AppManifest.xml that we are deploying we have key instead of explicit URL:
<App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest" Name="ShowAllRoomsApp" ProductID="{922a18aa-5592-b59a-4da9-4791baef02e7}" Version="1.0.0.0"
SharePointMinVersion="15.0.0.0">
<Properties>
<Title>SomeTitle</Title>
<StartPage>~remoteAppUrl/Pages/Default.aspx?{StandardTokens}</StartPage>
If we use as
https://technet.microsoft.com/en-us/library/jj655398.aspx recommends, we cannot specify Redirect Url as we can do this on
/_layouts/appinv.aspx
So now it seems like the only way to deploy this kind of solution is using appinv.aspx page.Or must we apply this URL in AppManifest on developing stage in Visual Studio?
What did I miss?
P. S. Even if I use /_layouts/appinv.aspx after powershell commandlets, I get error.hi,
to deploy provider hosted app you need 2 things
1. Client ID
2. Redirect URL.
What you can do you can generate app from visual studio using clientID and URL from developer enviornment.
Now a app file is just a simple compressed zip file if you rename it as .zip and extract you will find AppManifest
inside it. So to create an app for Testing enviornment what you have to to Get the CLient ID (from AppRegNew.aspx) in testing enviornment. Unzip .App file change the AppManifest with testing client ID and URL than again zip file and rename as .app.
Now if you upload this file it will work.
To automate this scenerio i have created a simple windows Application in which i Pass the Client ID and StartURl and an App File it unzips the app file make changes to app and again zip it.
public static class AppPackageHelper
public const string StartUrlExpression = "{0}?{1}";
public const string StandardToken = "{StandardTokens}";
public static string Publish(string appPath, string ClientId,string StartUrl)
string tempDir = string.Empty;
string outPutFile = string.Empty;
try
string parentDir = System.IO.Path.GetDirectoryName(appPath);
outPutFile = System.IO.Path.Combine(parentDir, ClientId + "-Winshuttle.app");
tempDir = System.IO.Path.Combine(parentDir, ClientId.ToString());
Directory.CreateDirectory(tempDir);
int lastInd = appPath.LastIndexOf('.');
string tempPath = string.Empty;
string targetFilePath = string.Empty;
string cabPath = System.IO.Path.Combine(tempDir, System.IO.Path.GetFileNameWithoutExtension(appPath) + ".cab");
FileInfo fInfo = new FileInfo(appPath) { IsReadOnly = false };
File.Copy(appPath, cabPath);
XDocument doc = null;
string appManifest = string.Empty;
using (ZipArchive zipArch = ZipFile.Open(cabPath, ZipArchiveMode.Update))
appManifest = string.Format(@"{0}\AppManifest.xml", Directory.GetParent(cabPath).FullName);
ZipArchiveEntry manifestEntry = zipArch.Entries.LastOrDefault(e => e.Name.ToLower() == "appmanifest.xml");
manifestEntry.ExtractToFile(appManifest);
doc = XDocument.Load(appManifest);
XNamespace ns = doc.Root.GetDefaultNamespace();
string defaultUrl = string.Format(StartUrlExpression, StartUrl.TrimEnd('/'), StandardToken);
doc.Descendants(XName.Get("StartPage", ns.NamespaceName)).First().Value = defaultUrl;
doc.Descendants(XName.Get("RemoteWebApplication", ns.NamespaceName)).First().Attribute(XName.Get("ClientId")).Value = setupInfo.ClientId.ToString();
doc.Save(appManifest);
if (manifestEntry != null)
manifestEntry.Delete();
zipArch.CreateEntryFromFile(appManifest, "AppManifest.xml");
int totEnt = zipArch.Entries.Count;
for (int e = 0; e < totEnt; e++)
if (zipArch.Entries[e].Open().Length == 0)
//if (zipArch.Entries.Count > totEnt && e >= totEnt) break;
//zipArch.CreateEntry(zipArch.Entries[e].FullName);
File.Delete(appManifest);
if (File.Exists(outPutFile))
File.Delete(outPutFile);
File.Move(cabPath, outPutFile);
return outPutFile;
catch
throw;
finally
if (System.IO.Directory.Exists(tempDir))
System.IO.Directory.Delete(tempDir, true);
return outPutFile;
using System.IO.Compression.FileSystem.dll.
Also if you want to do it using powershell You need to do the same thing unzip-> changes values-> zip
So basic thing is You need to ahve only valid AppManifest file which contains 2 valid values Client Id and StartUrl
if you changes it inside appmanifest manuall than it will also work. Using above code you can create a console Application to do it. You can use powershell it just that i dont know how to zip unzip in powershell but i am pretty sure you can easily find it
on searching.
Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer -
Search and Replace text in file using PowerShell
I want to schedule a script in PowerShell to search a directory for an XML file for a particular text string and replace it with a different text string and then save the file with the same name, the name of the file
will change each time the script is run on a daily basis. There will only be one XML file in the location when the scheduled script is run.
I have never used PowerShell but am familiar with batch file commands, can anyone please help!!
KevinSHi Kevin,
I’m writing to just check in to see if the suggestions were
helpful. If you need further help, please feel free to reply this post directly so we will be notified to follow it up.
If you have any feedback on our support, please
click here.
Best Regards,
Anna
TechNet Community Support -
Manipulating XML file using flex 2.0
Hi,
how to add contents in to xml file using flex 2.0, ie i
actually wants to write data in to a xml file, so that data to be
appended at the end of the file.
KumarYou can't! Well, at least Flex cannot do this. All Flex can
do is send this data -- any data -- to the server and it's up to
you how you want to append this data to a file on the server.
You see, flex can't write to local files. If you looking for
client side file manipulation, take a look at Flex's desktop
brother call AIR!
ATTA -
Creating XML File Using xmldom Package
How can I create an XML file from scratch using the PL/SQL xmldom package?
I want to create an XML file using the xmldom package instead of building the individual tags as strings of VARCHAR2 character data. There is quite a bit of documentation regarding manipulating input XML files using DOM -- but not for creating XML files from scratch given known "tagnames" (<lastName>) and retrieved database "values" ("Smith").
<person>
<lastName>Smith</lastName>
</person>
Is there any documentation that you can recommend?
Thank you.Here is an example.
The create_file procedure creates the file.
The other procedures are generic procs that can be used with any XML.
PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
pi_root_tag IN VARCHAR2,
po_root_element OUT xmldom.domelement,
po_root_node OUT xmldom.domnode,
pi_doctype_url IN VARCHAR2) IS
xmldoc xmldom.DOMDocument;
root xmldom.domnode;
root_node xmldom.domnode;
root_element xmldom.domelement;
record_node xmldom.domnode;
newelenode xmldom.DOMNode;
BEGIN
xmldoc := xmldom.newDOMDocument;
xmldom.setVersion(xmldoc, '1.0');
xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
-- Create the root --
root := xmldom.makeNode(xmldoc);
-- Create the root element in the file --
create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
po_xmldoc := xmldoc;
po_root_node := root_node;
po_root_element := root_element;
END create_file_with_root;
PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
pi_element_name IN VARCHAR2,
pi_parent_node IN xmldom.domnode,
po_new_element OUT xmldom.domelement,
po_new_node OUT xmldom.domnode) IS
element xmldom.domelement;
child_node xmldom.domnode;
newelenode xmldom.DOMNode;
BEGIN
element := xmldom.createElement(pi_xmldoc, pi_element_name);
child_node := xmldom.makeNode(element);
-- Append the new node to the parent --
newelenode := xmldom.appendchild(pi_parent_node, child_node);
po_new_node := child_node;
po_new_element := element;
END create_element_and_append;
FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
parent_node xmldom.domnode;
child_node xmldom.domnode;
child_element xmldom.domelement;
newelenode xmldom.DOMNode;
textele xmldom.DOMText;
compnode xmldom.DOMNode;
BEGIN
create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
parent_node := child_node;
-- Create a text node --
textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
child_node := xmldom.makeNode(textele);
-- Link the text node to the new node --
compnode := xmldom.appendChild(parent_node, child_node);
RETURN newelenode;
END create_text_element;
PROCEDURE create_file IS
xmldoc xmldom.DOMDocument;
root_node xmldom.domnode;
xml_doctype xmldom.DOMDocumentType;
root_element xmldom.domelement;
record_element xmldom.domelement;
record_node xmldom.domnode;
parent_node xmldom.domnode;
child_node xmldom.domnode;
newelenode xmldom.DOMNode;
textele xmldom.DOMText;
compnode xmldom.DOMNode;
BEGIN
xmldoc := xmldom.newDOMDocument;
xmldom.setVersion(xmldoc, '1.0');
create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
-- Create the record element in the file --
create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
-- Create the record element in the file --
create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
-- write the newly created dom document into the buffer assuming it is less than 32K
xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
EXCEPTION
WHEN xmldom.INDEX_SIZE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
WHEN xmldom.DOMSTRING_SIZE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'String Size error');
WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
WHEN xmldom.WRONG_DOCUMENT_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
WHEN xmldom.INVALID_CHARACTER_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
WHEN xmldom.NOT_FOUND_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Not found error');
WHEN xmldom.NOT_SUPPORTED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
WHEN OTHERS THEN
dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
END create_file; -
Reading XML file using BAPI and then uploading that xml file data into SAP
I am getting a xml file from Java server. I need to take
data from this file using BAPI and need to upload into SAP using SAP.
Please tell me how to read XML files using BAPI's.<b>SDIXML_DATA_TO_DOM</b> Convert SAP data (elementary/structured/table types) into DOM (XML
<b>SDIXML_DOM_TO_XML</b> Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
<b>SDIXML_DOM_TO_SCREEN</b> Display DOM (XML)
<b>SDIXML_DOM_TO_DATA</b>
data: it_table like t001 occurs 0.
data: l_dom TYPE REF TO IF_IXML_ELEMENT,
m_document TYPE REF TO IF_IXML_DOCUMENT,
g_ixml TYPE REF TO IF_IXML,
w_string TYPE XSTRING,
w_size TYPE I,
w_result TYPE I,
w_line TYPE STRING,
it_xml TYPE DCXMLLINES,
s_xml like line of it_xml,
w_rc like sy-subrc.
start-of-selection.
select * from t001 into table it_table.
end-of-selection.
initialize iXML-Framework ****
write: / 'initialiazing iXML:'.
class cl_ixml definition load.
g_ixml = cl_ixml=>create( ).
check not g_ixml is initial.
write: 'ok'.
create DOM from SAP data ****
write: / 'creating iXML doc:'.
m_document = g_ixml->create_document( ).
check not m_document is initial.
write: 'ok'.
write: / 'converting DATA TO DOM 1:'.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'IT_TABLE'
DATAOBJECT = it_table[]
IMPORTING
DATA_AS_DOM = l_dom
CHANGING
DOCUMENT = m_document
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
check not l_dom is initial.
write: / 'appending DOM to iXML doc:'.
w_rc = m_document->append_child( new_child = l_dom ).
if w_rc is initial. write 'ok'.
else. write: 'Err =', w_rc.
endif.
visualize iXML (DOM) ****
write: / 'displaying DOM:'.
CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
EXPORTING
DOCUMENT = m_document
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
convert DOM to XML doc (table) ****
write: / 'converting DOM TO XML:'.
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = m_document
PRETTY_PRINT = ' '
IMPORTING
XML_AS_STRING = w_string
SIZE = w_size
TABLES
XML_AS_TABLE = it_xml
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
write: / 'XML as string of size:', w_size, / w_string.
describe table it_xml lines w_result.
write: / 'XML as table of', w_result, 'lines:'..
loop at it_xml into s_xml.
write s_xml.
endloop.
write: / 'end of processing'.
end of code
Hope this will be useful.
regards
vinod
Maybe you are looking for
-
App to convert long voice memos to text
Is anyone aware of an app (on Mac or iPhone) that can convert long (over a couple minutes) dictation to text? Dragon Dictation for iPhone works great, but it only handles recordings up to 30 seconds. It seems like there would at least be some Mac app
-
Cannot connect to App Store nor to iTunes (support did not help)
Specific request: I have never been able to connect to the iTunes Store Details:Describe the alert message you received: Have never been able to connect to the App store, nor to itunes (support not able to help). New MBPro last August, running OS 10.
-
Is it possible to creat a playlist from the 'Up Next' list?
That may seem odd, but the reason is this. For our labs I'd like to crate playlist that play files from our shared libraries. Cut down on the piracy of our vast music collection in our university music dept.
-
Regarding Adding Custom Fields to VTTK and VT01n transaction.
Hi, We need to add few custom fields to Shipment header table VTTK. Also, these fields should be reflected in 'Additional Data' tab of transaction VT01n/VT02n for editing and should be available for display in VT03n. If anyone has done this, please p
-
Hi all, I just purchased a 5th generation Airport Extreme to replace my home router. I previously had a Linksys wireless G which gave up on me. I've got a handful of computers that will be hooked up to the router. One of them is a Windows machine and