Forcing XML from String containing prefix

Is there way to create an XML node from a String which contains a prefix?
example:
var str:String = "<w:body>content</w:body>";
var newXML:XML = new XML(str);
This returns:         The prefix "w" for element "body" is not bound.
Is there a way to force this?
I have tried adding a namespace to w   but with no luck.

In a strict sense, using CDATA feels like a hack. It, perhaps, makes sense only if string in your example will eventually become a text() value of another node.
In your case "w" is obviously a namespace. So, you should explore how to get and make your XML aware of this name space.
For example the following works:
var str:String = "<w:node xmlns:w=\"http://www.microsoft.com/\"><w:body >content</w:body></w:node>";
var newXML:XML = new XML(str);

Similar Messages

  • Exporting XML from a container

    Getting XML documents into an XmlContainer seems easy enough, but how do I get them back out again into XML? I don't see anything in API that will export the documents once they're placed in the containers.
    The reason I'd like to do this is to use BDB XML with a source-control system. Basically, each user would check out a bunch of XML files from source control and create a local container. As changes to the XML files get checked in, they would update and re-add the changed XML files to their local container. When they make changes to their local xml data, I'd like to programmatically determine which documents changed (that part I can do myself) and then export those "edited" documents from the container back into XML format. Then the users can check in their changed documents.
    This seems like it would work except that there's no way to export XML documents once they're placed in the XmlContainer. I suppose I could write my own exporter without great difficulty, but it seems like such a basic thing that I feel like I must be missing something somewhere.
    Is there really no built-in export-to-xml capability?

    Hi Devnull,
    Getting XML documents into an XmlContainer seems easy
    enough, but how do I get them back out again into
    XML? I don't see anything in API that will export
    the documents once they're placed in the containers.If you want to export all the documents held by a container you can simply use the dbxml shell:
    dbxml>getDocuments
    dbxml>print >container_name.xml
    This seems like it would work except that there's no
    way to export XML documents once they're placed in
    the XmlContainer. I suppose I could write my own
    exporter without great difficulty, but it seems like
    such a basic thing that I feel like I must be missing
    something somewhere.Not quite sure if you want to export each document from the container in its own individual xml file or all the documents in a single xml file (if this is the case use the suggested shell commands, or implement it programmatically).
    A couple of methods that you could use to implement the exporting functionality that you desire are:
    o XmlContainer::getAllDocuments http://www.oracle.com/technology/documentation/berkeley-db/xml/api_cxx/XmlContainer_getAllDocuments.html
    -> using this method you could retrieve all the documents inside an xml container, as an xml result set
    o XmlResults::next
    http://www.oracle.com/technology/documentation/berkeley-db/xml/api_cxx/XmlResults_next.html
    -> use this method to iterate through the result set and get each document
    o XmlDocument::getContent
    http://www.oracle.com/technology/documentation/berkeley-db/xml/api_cxx/XmlDocument_getContent.html
    -> use this method to put the content of an xml document from the result set in a string; you could write it into an individual xml file or append it to a single xml file
    Regards,
    Andrei Costache
    Berkeley DB
    Oracle Support Services

  • Extracting the xml from string and parse it

    Hi all,
    I have a webservice, and calling one of the methods, returns xml data but store this data in a string.
    For example:
    String str = keysstub.getUserLMLArray(UserID,hash, Provider, Filter.ALL,TimeStampString).getXmlResults();returns <id>123456</id><id>123457</id><id>123458</id><id>123459</id><id>123461</id>and stores it in str.
    I have to take read this xml from the string and parse it accordingly to retreive the data from it.
    Please suggest how i can parse this xml from the string. it will be of great help. Code snippets from anyone would be of great help
    Thanks and Regards,
    Shikha

          * Get DOM document from a string containing valid XML.
          * @param string String to read XML content from.
         * @param varargs Optional arguments: 1: Validating?, 2: NamespaceAware?
          * @return DOM document or null if failed.
         * @throws Exception if failed.
         static public Document toDocument(String string, boolean... varargs) throws Exception {
            Document result = null;
            if (string != null) {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                if (varargs != null && varargs.length > 0) {
                    int count = varargs.length;
                    if (count > 0) {
                        factory.setValidating(varargs[0]);  //needs error handler
                    if (count > 1) {
                        factory.setNamespaceAware(varargs[1]);
                DocumentBuilder db = factory.newDocumentBuilder();
                result = db.parse(new InputSource(new StringReader(string)));
            }//else: input unavailable
            return result;
        }//toDocument()and don't forget that the string must be valid xml, so in your example the header is missing and the first element must embrace all subsequent elements, e.g.
    <?xml version="1.0"?>
    <ids>
    <id>123456</id><id>123457</id><id>123458</id><id>123459</id><id>123461</id>
    </ids>

  • Include xml from string

    If this xml would have been in file I could have used following code:
    <?xml version="1.0" encoding='WINDOWS-1252'?>
    <?xml-stylesheet type="text/xsl" href="t.xsl" ?>
    <page xmlns:xsql="urn:oracle-xsql">
    <xsql:include-xsql href="order_id_seq.xsql" reparse="no" />
    <xsql:include-xml href="order.xml"/>
    </page>
    But i will be getting xml as string .so could you please tell me how can i include a xml which i will be receiving as a string in xsql .
    Thanks

    I would like to correct the version informaiton. We are using SUN JAVA WEBSERVICES DEVELOPERS PACK (JWSDP1.1).
    Nathan

  • Xerces - Parse XML from String

    I am trying to parse an xml string using Xerces.
    I have the following code:
    String xml = <segments meters="8643" seconds="538" distance="5.4 mi" time="8 mins"><segment id="seg0"  pointIndex="0" meters="122" seconds="11"  distance="0.1 mi"  time="11 secs">Head  <b>southwest</b> from <b>B Ave NE</b>
    </segment>
    <segment id="seg1" pointIndex="2" meters="239" seconds="22" distance="0.1 mi" time="21 secs">Turn <b>left</b> at <b>19th St NE</b></segment>
    <segment id="seg2" pointIndex="5" meters="2985" seconds="192" distance="1.9 mi" time="3 mins">Turn <b>right</b> at <b>1st Ave NE</b></segment>
    <segment id="seg3" pointIndex="43" meters="3280" seconds="211" distance="2.0 mi" time="3 mins">Continue on <b>1st Ave SW/1st Ave NW</b></segment>
    <segment id="seg4" pointIndex="96" meters="158" seconds="10" distance="0.1 mi" time="10 secs">Bear <b>right</b> at <b>US-151-BR S</b></segment>
    <segment id="seg5" pointIndex="102" meters="1859" seconds="93" distance="1.2 mi" time="1 min">Turn <b>right</b> at <b>16th Ave SW</b></segment>;
    XMLReader reader = new SAXParser();
    reader.setContentHandler(new Handler());
    reader.parse(xml);I am getting the followoing error:
    org.xml.sax.SAXParseException: File "<segments meters="8643" seconds="538" distance="5.4 mi" time="8 mins"><segment id="seg0" pointIndex="0" meters="122" seconds="11" distance="0.1 mi" time="11 secs">Head  <b>southwest</b> from <b>B Ave NE</b></segment><segment id="seg1" pointIndex="2" meters="239" seconds="22" distance="0.1 mi" time="21 secs">Turn <b>left</b> at <b>19th St NE</b></segment><segment id="seg2" pointIndex="5" meters="2985" seconds="192" distance="1.9 mi" time="3 mins">Turn <b>right</b> at <b>1st Ave NE</b></segment><segment id="seg3" pointIndex="43" meters="3280" seconds="211" distance="2.0 mi" time="3 mins">Continue on <b>1st Ave SW/1st Ave NW</b></segment><segment id="seg4" pointIndex="96" meters="158" seconds="10" distance="0.1 mi" time="10 secs">Bear <b>right</b> at <b>US-151-BR S</b></segment><segment id="seg5" pointIndex="102" meters="1859" seconds="93" distance="1.2 mi" time="1 min">Turn <b>right</b> at <b>16th Ave SW</b></segment></segments>" not found.
         at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1219)
         at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:501)
         at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:314)
         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1097)
         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1139)
         at com.shiftyeyes.xmlTest.main(xmlTest.java:34)
    Exception in thread "main" anyone know how I can fix this? Thanks!!

    reader.parse(new InputSource(new StringReader(xml)));

  • Parse XML from string.

    I have writen simple fuction which have one parameter of String type. In this parameter i am sending an XML string. Is there anyone who knows how to parse this XML-String ?
    Thanks.

    parse(new StringReader(theString));

  • Building XML from relational data

    I need to create XML documents from relational data that conforms to an XML schema document. We need to store and query the XML documents we create.
    Therefore, we have decided to store the XML using the object model rather than as a CLOB
    i.e. register the schema with the XML DB which in turn creates the tables and object types that represent the schema.
    What is the best way build the XML document from the relational data ??
    Can I pass the relational data to the default constructors of the object types created by the schema registration ?? (and then create an XML document from the top level object instance using SYS_XMLGEN)
    Or should I build the xml from strings using XMLELEMENT,XMLFOREST built-in's when retrieving the data from the relational tables ?? OR use the XMLDOM package to build the document ??
    Would appreciate any advice on the best approach.

    There are basically two ways to join your document fragments with SQLX:
    1/. With xmlForest
    e.g. SELECT XMLELEMENT ( "Emp",XMLForest(e.employee_id, e.lname, e.salary)) AS "result"
    FROM employees e WHERE employee_id > 1500 ;
    result
    <Emp>
    < employee_id >1769</ employee_id >
    < lname >Smith</ lname >
    < salary >200000</ salary >
    </Emp>
    2/. With nested invocations of xmlElement
    e.g. SELECT XMLELEMENT("Emp", XMLELEMENT("name", e.fname ||' '|| e.lname),
    XMLELEMENT ( "hiredate", e.hire)) AS "result"
    FROM employees e WHERE employee_id > 200 ;
    result
    <Emp>
    <name>John Smith</name>
    <hiredate>2000-05-24</hiredate>
    </Emp>
    <Emp>
    <name>Mary Martin</name>
    <hiredate>1996-02-01</hiredate>
    </Emp>

  • How to remove prefix namespace in Xml from XmlBean

    I am trying to generate XML from XML Bean but i am getting namespace prefix in all my xml elements.
    For example
    <abc:Cutomer xmlns:abc="http://www.xyz.com/pqr>
    <abc:Name>
    I don't have this namespace prefix in my XSD (imported in Weblogic workshop).
    Is there any way that I can remove this prefix from my xml elements?
    Also, I don't need xml namespace in my xml string.
    Is there any way that I can generate xml without having namespace?

    Hello ,
    I think this issue as been discussed earlier in this forum. Refer follwoing link..
    http://forums.bea.com/bea/message.jspa?messageID=400000090#400000090
    Regards,
    Kuldeep Singh.

  • Parsing XML from a String

    I have a servlet, this recieves an XML file from the client as a file input type from a html form. This XML is wrapped up in http headers and stuff. I parse the input stream from the client's http request to get a string containing the xml. This is fine.
    How do I now build an XML document from this string? The DocumentBuilder will take in files and InputStreams but I can't find anything that helps me?
    The only solution I've come up with is to write out the string to a temp file and then parse it back into a Document.
    Any ideas anyone?????

    Document doc = documentBuilder.parse(new InputSource(new StringReader(yourXMLString)));
    voila!

  • How to parse a string containing xml data

    Hi,
    Is it possible to parse a string containing xml data into a array list?
    my string contains xml data as <blood_group>
         <choice id ='1' value='A +ve'/>
         <choice id ='2' value='B +ve'/>
             <choice id ='3' value='O +ve'/>
    </blood_group>how can i get "value" into array list?

    There are lot of Java XML parsing API's available, e.g. JAXP, DOM4J, JXPath, etc.
    Of course you can also write it yourself. Look which methods the String API offers you, e.g. substring and *indexOf.                                                                                                                                                                                                                                                                                                                                                                                                               

  • Converting string(which is an xml from the java side) to xml in flex

    Hi,
       I have an xml from the java side which i send as string over amf. I need to convert this to xmllist or xml and bind it to a tree. Could some one help me in doing this. My label field needs to be displayName
    this is my xml that comes as string to the flex side
    <Menu>
      <MenuItem>
        <id>1</id>
        <displayName>Add</displayName>
        <menuList>
          <MenuItem>
            <id>3</id>
            <displayName>Form1</displayName>
            <menuList/>
          </MenuItem>
          <MenuItem>
            <id>4</id>
            <displayName>Form2</displayName>
            <menuList/>
          </MenuItem>
        </menuList>
      </MenuItem>
      <MenuItem>
        <id>2</id>
        <displayName>Delete</displayName>
        <menuList>
          <MenuItem>
            <id>5</id>
            <displayName>Form1</displayName>
            <menuList/>
          </MenuItem>
          <MenuItem>
            <id>6</id>
            <displayName>Form2</displayName>
            <menuList/>
          </MenuItem>
        </menuList>
      </MenuItem>
    </Menu>

    Well, for Binding you will probably need to further convert to XMLListCollection or ArrayCollection.
    Not sure.
    However, that is the way to convert String to XML.

  • Using content from Strings attributes in Prefix text

    Hello all you EDD experts out there,
    I did not find this specific info in the struct app dev guide, so I am hoping someone else has figured this out at some point in time. Maybe this is trivial to programmers, but I am not one of them and also I don't know what the prefix definition string will allow. So all help is greatly appreciated.
    In my structured framemaker EDD, I am using attributes to collect usage info. It would be nice to be able to use the Strings type attribute for this, instead of collating all the usage info into one single String type. But I need to use the content in a prefix string.
    Prefix: used in: \t<$attribute[validity]>
    If the validity attribute is of the Strings type and I enter multiple string values, only the first one shows up. How can I make all strings show in the prefix ?
    Thanks in advance for the golden tip :-)
    Jang

    Hello Russ and Van,
    I was kind of worried that I was crossing the limits of what FM EDDs can do. It is not a big deal - I can use the one string to store all values, as I have been doing so far. It just looks a little ugly when the string gets longer and the substrings do not wrap nicely. Of course going fully XML and XSLT etc would be another option but that is overkill for this particular client and they won't pay for that. Making the output a little nicer to look at is not a high priority, as this particular output is only shown in a catalogue of repository items to be used internally by my cient, i.e. it will never show in publications for users.
    Thanks for confirming my intuition that I should stop searching for the holy grail...
    Jang

  • How to associate an xml from httpservice to datagrid if the xml element name contains periods in it

    Following is the xml from an http service, how to associate
    this xml to a data grid (employee name, number) since it contains
    periods(dots) in xml element name.
    An early help is appreciated.....
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <com.companyx>
    <person>
    <employee.data>
    <employee.name>mrx</employee.name>
    <employee.number>1001</employee.number>
    </employee.data>
    <employee.data>
    <employee.name>mry</employee.name>
    <employee.number>1002</employee.number>
    </employee.data>
    <employee.data>
    <employee.name>mrz</employee.name>
    <employee.number>1003</employee.number>
    </employee.data>
    <page>0</page>
    </person>
    </com.companyx>
    Thanks,
    Vijay Karthik

    HI
    GOOD
    IT IS POSSIBLE IN ABAP
    Extensible Markup Language (XML) is a simple, very flexible text format derived from SGML (ISO 8879). Originally designed to meet the challenges of large-scale electronic publishing, XML is also playing an increasingly important role in the exchange of a wide variety of data on the Web and elsewhere.
    XSD->
    XML Schemas express shared vocabularies and allow machines to carry out rules made by people. They provide a means for defining the structure, content and semantics of XML documents. in more detail.
    XDS->
    XDS can process data images from CCD-, imaging-plate, and multiwire-detectors in a variety of formats. Detector specific Input file templates greatly simplify the use of XDS; they are provided as part of the documentation.
    XDS runs under Unix or Linux on a single server or a grid of up to 99 machines of the same type managed by the MOSIX system; in addition, by using OpenMP, it can be executed in parallel on up to 32 processors at each node that share the same address space.
    http://www2.stylusstudio.com/SSDN/default.asp?action=9&fid=23&read=2926
    /people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
    THANKS
    MRUTYUN

  • Receive xml as string from OSB and pass it to Bpel

    I was given xml and DTD by our external partners. I need to receive this xml, parse this and insert some of the
    values of the elements into DB.
    Question1:
    Since I don't have WSDL, can I receive xml in string and pass it on to OSB BS which calls Bpel process?
         If yes, how and can I get any example?
    How do I set up osb bs service to talk to bpel?
    I have installed oracle soa suite 10g with patch set 4. This runs with Oracle AS. I have my Bea weblogic 10.3 with OSB installed.
    Both the servers are running seperately.

    If I use
    string to xml --- fn-bea:inlinedXML()
    How do I extract a value of an element? When I log the xml that got extracted from a string, I only see the values of elements with no element names:
    eg: if incoming string format of xml is:
    <Customer>
    <name>aaa</name>
    <address>bb</address>
    </Customer>
    After fn-bea:inlinedXML($body)
    I see:
    aaa
    bbb
    in the log, but with no element names

  • CRIO: Unflatten from string into lvclass not working in deployment

    Hello,
    I am working on a problem for some hours now and I need some help.
    I am using a cRIO-9022. I need to do some tasks, and I created a couple of classes which contain the parameters and the methods. They contain using dynamic dispatch VIs. I have an array of these classes (all derived from a parent class) which is my "configuration". I am using "flatten to string" and saving those file on disk. "Unflatten from string" is working fine. These file is created on a LV WIndows Application.
    I need to use this file on my cRIO: Unflatten from string, and then work with the array of my classes. When running the cRIO Main VI it's working fine. But when building the application and deploying it as startup, it's not working. I am getting:
    Error 1403 occurred at Unflatten From String in Gantry CommEngine.vi->RT Main.vi
    Possible reason(s):
    LabVIEW:  Attempted to read flattened data of a LabVIEW class. The data is corrupt. LabVIEW could not interpret the data as any valid flattened LabVIEW class.
    What I tried so far:
    - Added the whole lvlib containing the classes and also every single class to "Source files / always included".
    - Created constants of the array (containing the classes) to the VI (forcing LV to include the classes?)
    - Loaded the file from cRIOs flash and also by shared variable
    What else can I do?
    Thanks a lot for support!

    I tried to reproduce the matter, but couldn't. 
    I attached my example to the post. 
    What it does:
    It creates a class with only a string a bool and a number. This class oblect is saved to C:/somename.xml. The number is a random number.
    In the second case the same file is read and the number broadcasted to a variable.
    It worked quite fine building it as a startupexe.
    Nothing else was necessary. Does it work for you?
    Attachments:
    class exe.zip ‏45 KB

Maybe you are looking for

  • Volume Too Low on Some Headpho

    I know the volume issue has been beaten to death. I bought my Zen Touch player in Canada, not in Europe. I have noticed that with the earbuds that came with the player, and with a pair of Panasonic headphones that came with a CD player I bought, the

  • 'L' Payment Method

    Experts, What's the corresponding payment method/description in English (say for US) for the corresponding 'L' payment method in Germany. All answers would be duly appreciated and rewarded with points. Thanks, Nandita

  • Why does safari close down when mac not in use

    This just recently started in the past few days to a week. When my computer goes to sleep, safari shuts down. Any pages I have left open to come back and look at are gone. I know I can use history, but this has a never happened before. Is safari corr

  • Captivate 6 crashes when publishing Media - MP4

    It alwas crashes the firs time I try and I have to restart the progrm. On the second or thied try it sometimes works.

  • How to handle a DC in NWDI

    Hi all,             i created one DC in NWDI.The structure of the DC which i can see in my Webdynpro Explorer is 1)DC MetaData 2)WebDynpro 3)Dictonaries 4)Src i created an application through WebDynpro->CreateApplication with a component and a window